I was looking for script which allows crop iamges by their transparency.
Python comes with help.
You only need to instal PIL librarry
pip install pillow
Script:
Croppes *.png
files in current directory, and save under ./cropped
directory (you need to create it firstly)
from PIL import Image
import os
def crop_to_content(file_name,file_output):
image=Image.open(file_name)
imageBox = image.getbbox()
cropped=image.crop(imageBox)
cropped.save(file_output)
if __name__ == '__main__':
directory = r'.'
for filename in os.listdir(directory):
if filename.endswith(".png"):
crop_to_content(filename, "./cropped/"+filename)
else:
continue