Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45018 > unrolled thread

Re: PIL: check if image is animated

Started bySven <svenito@gmail.com>
First post2013-05-09 09:22 +0100
Last post2013-05-09 09:22 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: PIL: check if image is animated Sven <svenito@gmail.com> - 2013-05-09 09:22 +0100

#45018 — Re: PIL: check if image is animated

FromSven <svenito@gmail.com>
Date2013-05-09 09:22 +0100
SubjectRe: PIL: check if image is animated
Message-ID<mailman.1487.1368087777.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Figured out my issue. I did called the check_animated function more than
once and the second call causes the exception unless I seek back to 0


On 6 May 2013 21:57, Sven <svenito@gmail.com> wrote:

> Hello,
>
> I am trying to check if an image is animated. I can't rely on the
> extension as it may be a gif that's been renamed to .jpg or something else
> and is still animated.
>
> I thought that this used to work:
>
> from PIL import Image
>
>
> def check_animated(img):
>     try:
>         img.seek(1)
>     except (EOFError):
>         return 0
>     return 1
>
> img = Image('image.jpg')
> print "animated?", check_animated(img)
>
> Regardless if it's animated or not I get this exception:
> ValueError: cannot seek to frame 1
>
> I need to return 0 or 1, so excuse not using True or False.
>
> Did the above get deprecated/change in a version at some point? Perhaps
> there's something I missed during install (using PIP). Are there any other
> ways to accomplish what I am trying to do, with or without PIL?
>
> Python 2.7, linux
>
> --
> ./Sven
>



-- 
./Sven

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web