c/programming · by maya_the_good_apple@sh.itjust.works · 157dimaging question in python How do I convert a batch of .pngs into a single .apng? 11 points · 9 comments · view on lemmy.world
9 Comments
mbirth@lemmy.ml · 8 pts · 157d
I'd use ImageMagick, but if you want to do it in plain* Python, here's an example: https://stackoverflow.com/a/79683407
* Well, you'll need pyAPNG.
maya_the_good_apple@sh.itjust.works · 3 pts · 157d
I used pillow. It has apng support now.
seedlord_com@lemmy.zip · 5 pts · 157d
On top of the other advice, Pillow is definitely worth considering for this. It’s a solid library that fits this use case perfectly.
maya_the_good_apple@sh.itjust.works · 3 pts · 157d
I got it to work. Yay!
https://sh.itjust.works/pictrs/image/ae3e684e-dacd-4b98-8306-bc68715e3587.apng
one_old_coder@piefed.social · 2 pts · 156d
Nice shitpost! What was your code to achieve this?
maya_the_good_apple@sh.itjust.works · 2 pts · 156d
I currently don't have the code. I didn't save it...
I'll give you a rough idea of what the modified code stack overflow did.
They imported pillow module.
Took the 6 labelled images from their storage.
Appended the images with a set delay of 100ms and saved it as one.
I'm not a coder, so I can't remember the python code.
one_old_coder@piefed.social · 2 pts · 156d
Don't be shy, you are a coder now. Enjoy the chaos!
Kissaki@programming.dev · 3 pts · 156d
!python@programming.dev
maya_the_good_apple@sh.itjust.works · 1 pts · 156d
I don't remember where the original code is, maybe I forgot to save it but it's fine. I found a site that explains the apng module.
https://pypi.org/project/apng/