Is it possible to remape (for example) a 256-colors-gif image into a 128-colors or 64-colors gif image in Python?
I tried it using the imageio library
import imageio
def myfunction(inputgif, outputgif, duration):
gifimage = imageio.mimread(inputgif)
for i in range(len(gifimage)):
gifimage[i] = gifimage[i]/4
with imageio.get_writer(outputgif, mode='I', duration=duration) as writer:
for x in range(len(gifimage)):
writer.append_data(gifimage[x])
writer.close()
It's working, but, the problem is that the image file still thinks that "his universe" is 256 possible values for the color (from 0 to 255), not from 0 to 64 (since I divided all the values by 4). Which makes the image goes only darker, instead of using a 64 (4 bits) possible colors.
My goal is to obtain a lossy data compression by decreasing number of colors.