1

I want to make script which liquid-rescales GIFs frame by frame, but I stuck into the problem. Every time it just distorts image, and it looks like previous frame isnt disposed. I used this answer as base for my script:

In [19]: with Image() as result:
    ...:     with Image(filename='file.gif') as source:
    ...:         for frame in source.sequence:
    ...:             x, y = frame.width, frame.height
    ...:             frame.liquid_rescale(x//2, y//2)
    ...:             frame.resize(x, y)
    ...:             result.sequence.append(frame)
    ...:     result.save(filename='res.gif')

Here is source image: http://maxlunar.insomnia247.nl/files/file.gif

And my result image: http://maxlunar.insomnia247.nl/files/res.gif

I'm not sure how do I fix that mess. Also I plan to do all manipulations with images in memory (I download them from URLs right into io.BytesIO object, and this is required because I plan to use it in multithreaded application, so it should be thread/process-safe). Thanks in advance.

MaxLunar
  • 653
  • 6
  • 24
  • Is it possible that some frames have different widths/heights, compared to other frames? If you do `print(x,y)` inside the loop, does it display the same output for each iteration? – Kevin Aug 23 '18 at 18:17
  • @Kevin i'll try to reproduce it, but I dont think it is the problem, as I restore the initial size of frame. It just looks like first unchanged frame is on background, and all other are semi-transparent – MaxLunar Aug 23 '18 at 19:18
  • @Kevin first frame is 500x500, and all others are varying 130-150x190-210. Very strange, but anyway, how can I edit them properly? I see now why theyre screwed up, but this doesn't help me... – MaxLunar Aug 25 '18 at 21:38

0 Answers0