Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

put cropped image in original image name folder python

filepath = '/some/file/path/Frames/'

for filename in os.listdir(filepath):
    if "." not in filename:
        continue
    ending = filename.split(".")[1]
    if ending not in ["jpg", "gif", "png"]:
        continue

    try:
        image = Image.open(os.path.join(filepath, filename))
    except IOError as e:
        print("Problem Opening", filepath, ":", e)
        continue

    image = image.crop((535, 40, 600, 90))

    name, extension = os.path.splitext(filename)
    print(name + '_cropped.jpg')
    image.save(os.path.join('/some/file/path/Frames/Cropped', name + '_cropped.jpg'))
Comment

PREVIOUS NEXT
Code Example
Python :: os.path.dirname(__file__) 
Python :: Mac: Access your iCloud Documents folder with Jupyter Notebook or JupyterLab 
Python :: pd dataframe 
Python :: recursive python 
Python :: pytorch dataloader to device 
Python :: How to Loop Through Sets in python 
Python :: automatic regex generator python 
Python :: save artist animation puython 
Python :: snakeviz python profile 
Python :: request login python 
Python :: cv2 and PIL BRG to RGB 
Python :: An example of how to associate a color to each bar and plot a color bar 
Python :: python remove vowels from string 
Python :: use model from checkpoint tensorflow 
Python :: how to calculate numbers with two zeros in python 
Python :: seaborn bar plot sort for weekday 
Python :: python string name out of mail 
Python :: flask or django 
Python :: python program to check whether a specified value is contained in a group of values 
Python :: how to get last element of list in python 
Python :: object function in python 
Python :: flask sqlalchemy case insensitive like 
Python :: To convert Date dtypes from Object to ns,UTC with Pandas 
Python :: python logging change handler level 
Python :: dataframe divided by rowsum 
Python :: pandas find column with max value for each row 
Python :: copy along additional dimension numpy 
Python :: python "urllib3" download and save pdf 
Python :: calculate the surface area of a cylinder python 
Python :: combination in python 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =