0

Is there any way to crop an animated gif set inside a QMovie widget? I'm running into the issue where my animated gif is too big for the QMovie widget so I'm only seeing the top left portion of the gif. The animated gif is stored inside a QByteArray.

I've tried opening it up with Pillow's Image.open, cropping with img.crop(...) and saving it back into the QByteArray but that ends up only cropping and saving the first frame of the animated gif.

If cropping the gif is not possible, is there a way to center the gif inside the QMovie widget so that I see the center section of the animated gif?

I'm working with Python 2.7 and PySide.

Thank you!

Yuuki
  • 33
  • 6
  • It seems that Pillow can't crop animated gifs correctly. However, imagemagick can do that as shown in [this answer](http://stackoverflow.com/a/14036766/344347), so you can try to use PythonMagick to achieve this. Another option is to crop the gif while displaying in the widget. If you want to do that, you should post the code related to displaying `QMovie`. Note that `QMovie` is not a widget, and you need to use something like `QLabel` to display it. – Pavel Strakhov Jun 19 '15 at 10:55
  • Is there a way to crop the gif while displaying in the widget? Yes, I do have QMovie in a QLabel as seen in my previous post [here](http://stackoverflow.com/questions/30895402/loading-animated-gif-data-in-qmovie). Using ImageMagick/PythonMagick is not an option for me at the moment. Thanks! – Yuuki Jun 19 '15 at 12:58
  • You can put `QLabel` into a `QScrollArea`, set its size, set scroll positions using `area.horizontalScrollBar().setValue(...)` and hide scrollbars using `area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)` (and similarly for vertical axis). – Pavel Strakhov Jun 20 '15 at 17:16
  • I've actually managed to avoid the need to crop the gif but your suggestion looks like it would work. If you've tested/used this method before, do you want to post this as an answer and I'll accept it? – Yuuki Jun 23 '15 at 14:48

0 Answers0