Last active
December 19, 2024 14:04
-
-
Save Staars/dad45b3e555a93943372fd7a35967078 to your computer and use it in GitHub Desktop.
GIF test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageSequence | |
import io | |
import requests | |
fname = 'img.gif' | |
id ='23041' | |
url = 'https://developer.lametric.com/content/apps/icon_thumbs/'+id+'_icon_thumb.gif' | |
r = requests.get(url) | |
open(fname , 'wb').write(r.content) | |
# Opening the input gif: | |
im = Image.open("img.gif") | |
# create an empty list to store the frames | |
frames = [] | |
# iterate over the frames of the gif as save | |
f = open("img.bin","wb") | |
buf = bytearray() | |
for frame in ImageSequence.Iterator(im): | |
frame = frame.convert("RGB") | |
for x in range(5,45,5): | |
for y in range(5,45,5): | |
r, g, b = frame.getpixel((x, y)) | |
buf.append(r) | |
buf.append(g) | |
buf.append(b) | |
print(r,g,b) | |
#frame.save(imgByteArr,frame=image.format) | |
#imgByteArr = imgByteArr.getvalue() | |
f.write(buf) | |
f.close() | |
print(len(buf)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment