Python: Converting GIF frames to PNG

I don’t think you’re doing anything wrong. See a similar issue here: animated GIF problem. It appears as if the palette information isn’t correctly treated for later frames. The following works for me: def iter_frames(im): try: i= 0 while 1: im.seek(i) imframe = im.copy() if i == 0: palette = imframe.getpalette() else: imframe.putpalette(palette) yield imframe … Read more

Superimpose heatmap on a base image OpenCV Python

Updated Answer — 29th April, 2022. After the repeated comments I have decided to update this post with a better visualization. Consider the following image: img = cv2.imread(‘image_path’) I obtained a binary image after performing binary threshold on the a-channel of the LAB converted image: lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB) a_component = lab[:,:,1] th = cv2.threshold(a_component,140,255,cv2.THRESH_BINARY)[1] … Read more

Resize image in Python without losing EXIF data

There is actually a really simple way of copying EXIF data from a picture to another with only PIL. Though it doesn’t permit to modify the exif tags. image = Image.open(‘test.jpg’) exif = image.info[‘exif’] # Your picture process here image = image.rotate(90) image.save(‘test_rotated.jpg’, ‘JPEG’, exif=exif) As you can see, the save function can take the … Read more