[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Exctract GIF comment from image

wingi

3/11/2008 4:53:00 PM

Hi,

simple question: The PIL does not support reading the optional
description in GIF Images.

http://www.pythonware.com/library/pil/handbook/form...

After some reasearch I could not find a python solution for this, any
suggestions?

Thanx, Wingi.
5 Answers

Miki

3/11/2008 5:18:00 PM

0

Hello Wingi,

> simple question: The PIL does not support reading the optional
> description in GIF Images.
>
> http://www.pythonware.com/library/pil/handbook/form...
>
> After some reasearch I could not find a python solution for this, any
> suggestions?
Use ImageMagick (www.imagemagick.org), "identify -verbose <image>"
should have the comments somewhere
in the output.
There also a python binding to ImageMagick but I have no experience
with it.

HTH,
--
Miki <miki.tebeka@gmail.com>
http://pythonwise.bl...

Guilherme Polo

3/11/2008 5:40:00 PM

0

2008/3/11, wingi@gmx.com <wingi@gmx.com>:
> Hi,
>
> simple question: The PIL does not support reading the optional
> description in GIF Images.
>
> http://www.pythonware.com/library/pil/handbook/form...
>
> After some reasearch I could not find a python solution for this, any
> suggestions?
>
> Thanx, Wingi.
>
> --
> http://mail.python.org/mailman/listinfo/p...
>

I did a quick thing here, try it and check if it solves the problem for you:

import os
import sys
import struct

def extract_comments(giffile):
fobj = open(giffile, 'rb')

giftype = fobj.read(6)
pf = struct.unpack('<hhBBB', fobj.read(7))[2]
if pf & 0x80:
pallete_size = 2 << (pf & 0x07)
fobj.read(3 * pallete_size)
# finished reading header

fsize = os.stat(giffile).st_size
while fobj.tell() != fsize:
mark = ord(fobj.read(1))

if mark == 0x21: # gif extension
label = ord(fobj.read(1))
is_comment = label == 254

# read the extension block
blocksize = ord(fobj.read(1))
while blocksize:
if is_comment:
print fobj.read(blocksize)
else:
fobj.read(blocksize)

blocksize = ord(fobj.read(1))

def main(args):
if len(args) < 2:
print "Usage: %s <gif file> ..." % args[0]
sys.exit(0)

for gif in args[1:]:
extract_comments(gif)

if __name__ == "__main__":
main(sys.argv)

--
-- Guilherme H. Polo Goncalves

wingi

3/12/2008 9:11:00 AM

0

On 11 Mrz., 18:39, "Guilherme Polo" <ggp...@gmail.com> wrote:
> 2008/3/11, wi...@gmx.com <wi...@gmx.com>:
>
> > Hi,
>
> > simple question: ThePILdoes not support reading the optional
> > description in GIF Images.
>
>
> I did a quick thing here, try it and check if it solves the problem for you:
>
Wow - thanx for the fast answer!

Yes it works and can use it ;-)

*smile*

Mack A. Damia

10/19/2011 1:22:00 PM

0

On Wed, 19 Oct 2011 09:09:25 -0400, gemjack
<geminijacksonis@yahoo.com> wrote:

>On Wed, 19 Oct 2011 03:11:05 -0700, Mack A. Damia
><mybaconbutty@hotmail.com> wrote:
>
>>On Tue, 18 Oct 2011 09:08:51 -0400, gemjack
>><geminijacksonis@yahoo.com> wrote:
>>
>>>
>>>http://mashable.com/2011/10/17/herman-cain-singin...
>>
>>Methinks you have to be brain dead to repost the same link and
>>information directly after the original. What's the point?
>
>A logical mind would assume that I didn't see your post. An even more
>astute observer would note that once I apparently did, I abandoned my
>thread as it is clearly irrelevant. Is this a first for you?

Look at the times and the dates. Your answer is incongruent.

>> I'm only
>>saying this for your own good; it makes you look like a dweeb, and you
>>even commented in my original thread, so you knew it was there.
>
>Yes, 4 hours after my new thread post, IOW, once I saw yours. Get a
>newsreader that provides dates and times please.

I have one. I think the answer resides in the fact that you don't
read other peoples' threads.

>(sigh) Very well, I hereby bequeath all credit to Sir/Lady Mack-nut
>for the uncovering of said video goodness. All monetary
>contributions, accolades, and grievances should be directed his/her
>way. Better now?
>
>>
>>??????????
>
>Get a life, this is only usenet. How do you deal with real problems?
>
>Hopefull this addresses your concerns and you can get on with your day
>now. We'll see I guess.

You're a fuckwit, and there's only one remedy:

<*plonk*>

gemjack

10/19/2011 3:45:00 PM

0

On Wed, 19 Oct 2011 06:21:47 -0700, Mack A. Damia
<mybaconbutty@hotmail.com> wrote:

>On Wed, 19 Oct 2011 09:09:25 -0400, gemjack
><geminijacksonis@yahoo.com> wrote:
>
>>On Wed, 19 Oct 2011 03:11:05 -0700, Mack A. Damia
>><mybaconbutty@hotmail.com> wrote:
>>
>>>On Tue, 18 Oct 2011 09:08:51 -0400, gemjack
>>><geminijacksonis@yahoo.com> wrote:
>>>
>>>>
>>>>http://mashable.com/2011/10/17/herman-cain-singin...
>>>
>>>Methinks you have to be brain dead to repost the same link and
>>>information directly after the original. What's the point?
>>
>>A logical mind would assume that I didn't see your post. An even more
>>astute observer would note that once I apparently did, I abandoned my
>>thread as it is clearly irrelevant. Is this a first for you?
>
>Look at the times and the dates. Your answer is incongruent.

Eh? Bit of a drama-queen over this aren't you? My New thread was
started at 9:08am on 9/18. Then I noticed your existing thread,
abandoned mine, and made a post in your thread later at 1:35pm. This
is an absurd battle your picking, reeks of an unstable amateur.

>>> I'm only
>>>saying this for your own good; it makes you look like a dweeb, and you
>>>even commented in my original thread, so you knew it was there.
>>
>>Yes, 4 hours after my new thread post, IOW, once I saw yours. Get a
>>newsreader that provides dates and times please.
>
>I have one. I think the answer resides in the fact that you don't
>read other peoples' threads.

True, I do not always refresh before posting. I'm just that kind of
crazy.

>>(sigh) Very well, I hereby bequeath all credit to Sir/Lady Mack-nut
>>for the uncovering of said video goodness. All monetary
>>contributions, accolades, and grievances should be directed his/her
>>way. Better now?
>>
>>>
>>>??????????
>>
>>Get a life, this is only usenet. How do you deal with real problems?
>>
>>Hopefull this addresses your concerns and you can get on with your day
>>now. We'll see I guess.

And 'see' we did, LOL!

>You're a fuckwit, and there's only one remedy:
>
> <*plonk*>

Yeah, this breaks my heart. But it gave me something to do while
drinking my breakfast.

-gj