<div dir="ltr">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</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 6 May 2013 21:57, Sven <span dir="ltr"><<a href="mailto:svenito@gmail.com" target="_blank">svenito@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>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.</div>
<div>
<br></div><div>I thought that this used to work:</div><div><br></div><div>from PIL import Image</div><div><br></div><div><br></div><div>def check_animated(img):</div><div>    try:</div><div><div>        img.seek(1)</div>

<div>    except (EOFError):</div><div>        return 0</div><div>    return 1</div><div><br></div><div>img = Image('image.jpg')</div><div>print "animated?", check_animated(img)</div><div>
<br></div><div>Regardless if it's animated or not I get this exception:</div><div><div>ValueError: cannot seek to frame 1</div><div><br></div><div>I need to return 0 or 1, so excuse not using True or False.</div>
<div><br></div><div>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?</div>

<div><br></div><div>Python 2.7, linux</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span></div><span class="HOEnZb"><font color="#888888">-- <br>./Sven
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>./Sven
</div>