Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

editing gifs with Perl

by martymart (Deacon)
on Dec 18, 2002 at 14:31 UTC ( [id://220843]=perlquestion: print w/replies, xml ) Need Help??

martymart has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I am hoping to write a script that will edit a gif (preferable just put a thin red diagonal line through it). Which Perl module would be most suited to help me with this, the GD module maybe?
Does anyone know of some sample scripts that might help me get started on this one... much appreciated.

Thanks in advance,
martymart

Replies are listed 'Best First'.
Re: editing gifs with Perl
by Flame (Deacon) on Dec 18, 2002 at 14:49 UTC

    Since the primary question has already been answered, I'll leave it at that, but I will mention that it is really not that wise to be using gif's too often anymore as recently the company that owns the GIF compression algorithm has started to assert its rights.

    If all you want is an image with transparency (or you don't take advantage of the animation capability) then I suggest you look at the PNG format, which GD does support. PNG is very similar to GIF, but it uses a different compression algorithm and can't be animated (yet, I hear rumors that they are working on that...)

    Well, there's my advice, take it or leave it, just be careful with those gifs, I doubt anyone here can conveniently afford a legal battle.

    Update: Oh yeah, several other file types also use the same compression algorithm, there was a discussion about this not too long ago... anyone that knows where it was feel free to post it as a reply or /msg me and i'll update this post again...





    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS | GMS

      PNG is very similar to GIF, but it uses a different compression algorithm and can't be animated (yet, I hear rumors that they are working on that...)

      The PNG equivalent of Animated GIFs are MNGs (Multiple-image Network Graphics.) As implied by the name, MNG was based on the PNG format to handle animated graphics. In addition to sharing a number of PNG's best features, it offers the following animation features:

      • Object/sprite based animation
      • Much better compression than animated GIFs
      • Frame differencing support
      • Nested loops (useful for complex animations)
      But MNGs are currently still in development and very few programs support it as of yet (the only program that springs to my mind is Netscape 6).

      -- Rozallin J. Thompson
      The Webmistress who doesn't hesitate to use strict;

        Well that's useful to know, what about Mozilla?



        My code doesn't have bugs, it just develops random features.

        Flame ~ Lead Programmer: GMS | GMS

      recently the company that owns the GIF compression algorithm has started to assert its rights.

      Heh! Well in that case they (Unisys) had better hurry and start suing people, because the clock is ticking and the patent is due to expire in six months (June 2003). Funny how things turn out, we were told to burn our GIFs and embrace PNG, and here we are in 2002, and GIFs are just as pervasive as ever. And now it seems that in six months time we won't even have to bother any more. I wonder how long it will take for the meme to die?

      Mind you, I like PNGs from an ethical point of view, but they suffer from a big flaw over GIFs: they are bigger. If you want all the functionality the specification has to offer they are indeed très cool, but if you just want to replace GIFs you're worse off in terms of space.

      Some more reading material on the GIF patent issue:



      print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

        The Portable Network Graphics (or PNG) file format features lossless compression, alpha channels, gamma correction and two-dimensional interlacing. PNGs (generally) compress better than GIFs by 5 - 25%. PNG supports 48-bit truecolor and 16-bit grayscale. Just remember that using truecolor images come at a cost of greatly increased file size.

        Recommended reading: everything at the PNG Home Site.

Re: editing gifs with Perl
by dda (Friar) on Dec 18, 2002 at 14:37 UTC
    Look at ImageMagic library and this perl module.

    --dda

Re: editing gifs with Perl
by gjb (Vicar) on Dec 18, 2002 at 14:50 UTC

    GD is also very nice for this kind of task.

    Hope this helps, -gjb-

      Just to add a FYI with regards to GD, the last version to support the gif format was version 1.19. This site has some patches that will restore GIF support in more current versions. Of course, be sure to read the disclaimer before downloading the patches.

      --
      "I don't intend for this to take on a political tone. I'm just here for the drugs." --Nancy Reagan
Re: editing gifs with Perl
by Sihal (Pilgrim) on Dec 18, 2002 at 15:19 UTC
    I'd say use PerlMagick (Image Magic and it's perl module ) if you are on a standard platform ( not a zSeries for example , on wich I never was able to install it properly)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://220843]
Approved by gjb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found