[DFW.pm] Changing colors in a gif using cgi

Tommy Butler dfwpm at internetalias.net
Tue Jan 8 17:47:57 PST 2013


Adding to what Matt just said, once you've handled the issues he just
explained, you'll be needing sysopen(), sysseek(), sysread(), and
syswrite().  Regular Perl IO won't work for you.

For image operations, I usually use the tried and true GD.pm

Without understanding your reasons for eschewing the use of modules in
your work on this particular project (while respecting your reasons all
the same), I'd like to just make some generalized points that a
surprising many Perl users sadly do not know.  Please don't take it as
an insult if you already know these things, as I make the following
statements for the benefit of the group as a whole:

While using modules is sometimes not an option-- for example you may be
working on something in a company with servers where you're not allowed
to install things-- it's no sign of weakness to take advantage of
everything Perl has to offer and try out a module.  Using the CPAN is a
hallmark of a strong Perl programmer, in the general opinion of the Perl
community over the years.  The graphics modules we've discussed are
written in C and are very fast.  You incur near zero penalty for using
such libraries, which are also optimized to work faster and more
efficiently at their specific tasks than what you'd be doing on your
own.  Unless you have a very compelling reason to do otherwise, Perl and
its community always recommend not to reinvent the wheel when the option
is on the table to use its (very) nice CPAN wheels for free.  If it's a
learning experience you seek, it's also of benefit to look at the source
code of these CPAN modules so you can see how others are doing what
you'd like to do on your own.  I always start looking at
http://search.cpan.org

Hope to see you at the meeting tomorrow night!

--Tommy Butler

On 01/08/2013 04:31 PM, Matthew Musgrove wrote:
>
> Jerry,
>
> You can’t just change a few bytes in an image file and be done with
> it.  If you don’t want to use a module, then you’ll need to be well
> versed in the various image file formats before you can ever start
> coding. Otherwise you won’t know what bits to look for, much less what
> values to use to get the change you are interested in.
>
>  
>
> Matt
>
>
>
> On Tue, Jan 8, 2013 at 4:16 PM, Jerry Kassebaum
> <kassebaumj at hotmail.com <mailto:kassebaumj at hotmail.com>> wrote:
>
>     How can I use Perl to read a non-text file in hex, change a few
>     individual bytes, and write it back? Would this work to change a
>     gif or png, or would I have to go down to binary?
>
>     I appreciate the ImageMagic answer I received before, and may have
>     to resort to that, but I would prefer to work with pure Perl
>     without loading a module. Surely there is a simple way to
>     read/write a file byte by byte?
>
>
>     Jerry Kassebaum
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/dfw-pm/attachments/20130108/4633794a/attachment-0001.html>


More information about the Dfw-pm mailing list