Advertisement
sissou123

Untitled

Jan 12th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | Source Code | 0 0
  1. import Image import sys image=Image.open('L_2d.png') image.load() imageSize = image.size imageBox = image.getbbox() imageComponents = image.split() rgbImage = Image.new("RGB", imageSize, (0,0,0)) rgbImage.paste(image, mask=imageComponents[3]) croppedBox = rgbImage.getbbox() print imageBox print croppedBox if imageBox != croppedBox: cropped=image.crop(croppedBox) print 'L_2d.png:', "Size:", imageSize, "New Size:",croppedBox cropped.save('L_2d_cropped.png')
  2. th
  3. Install Pillow
  4. pip install Pillow
  5. and use as
  6. from PIL import Image image=Image.open('L_2d.png') imageBox = image.getbbox() cropped = image.crop(imageBox) cropped.save('L_2d_cropped.png')
  7. for more:https://cuty.io/9Nq6cUDK6mO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement