submitted 2 years ago* (last edited 2 years ago) by to c/python@programming.dev
 

I am assisting in making a wiki for an old game, and we ripped the avatar GIFs from the games shop and want to have a catalog of them. What I need to do is to crop all the borders which are identical from 3,170 GIFs and maybe make background transparent.

I haven't used python in years, but I managed to cobble up something that almost works as a single image test, only issue is that it crops and outputs only the first frame:

from PIL import Image

if __name__ == "__main__":
    input_loc = "AvatarShopImages/80001.gif"
    output_loc = "Output/80001.gif"
    im = Image.open(input_loc)
    im = im.crop((4, 4, 94, 94))
    im.save(output_loc)

If it looks weird, it is because I copy/pasted some code and edited a lot out of it.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [S] 3 points 2 years ago (2 children)

Let me clarify, there are 3 THOUSAND GIFs that need to be cropped

  • source
  • parent
  • hideshow 4 child comments
  • [โ€“] 3 points 2 years ago*

    If they're all the same size and need cropped to the same size you could drop them all in one folder and run the ffmpeg command with *.gif. That should do all of them.

    You'd have to find a way to automate the output though.

  • source
  • parent