0

I have converted a gif in python but the transparency of the background is lost. I want to regain the transparency or find a code to remove the transpparency of the gif

import imageio
clip = os.path.abspath(".\Desktop\\Comp 1.mov")

def gifMaker(inputPath,targetFormat):
    outputPath = os.path.splitext(inputPath)[0]+targetFormat

    print(f'convertinig {inputPath} \n to {outputPath}')

    reader = imageio.get_reader(inputPath)
    fps = reader.get_meta_data()['fps']
    writer = imageio.get_writer(outputPath,fps=fps)
    for frames in reader:
        writer.append_data(frames)
        print(f'Frame{frames}')
    print('done!')
    writer.close()

gifMaker(clip,'.gif')```


emilliman5
  • 5,816
  • 3
  • 27
  • 37
  • I'm not familiar with imageio, but perhaps explicitly specifing the format would work? that is, `reader = imageio.get_reader(inputPath, format="RGBA")` and `writer = imageio.get_writer(outputPath,fps=fps, format="RGBA")` – Rotem Tal Aug 14 '19 at 14:24
  • And a clarification: the "RGBA" format includes an ALPHA (as 'A') parameter which effects transparency, if the default format is "RGB" the transparency would be overlooked – Rotem Tal Aug 14 '19 at 14:32
  • https://stackoverflow.com/questions/46850318/transparent-background-in-gif-using-python-imageio seems to be helpful. – aschultz Aug 14 '19 at 15:18

0 Answers0