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

Does anyone happen to know off hand if there is a way to go from a base64 var to a GD::Image?

I am using a JPEG image in base64 format. Would like to be able to put that image into a GD::Image so I can resize it, if necessary before I put it into a TK control.

--- Scott

Replies are listed 'Best First'.
Re: Base64 to GD::Image
by MZSanford (Curate) on Dec 19, 2001 at 22:19 UTC
    I have never done it, and this is untested, but i would guess :
    use MIME::Base64; use GD; ## get data into $var64 ... my $jpeg = decode_base64($var64); my $gd_image = GD::Image->newFromJpegData($jpeg); ## or, even : my $gd = GD::Image->newFromJpegData(decode_base64($var64));

    Once again, untested, but based on your problem and the perldoc's, thats my guess :)
    $ perl -e 'do() || ! do() ;' Undefined subroutine &main::try
      What you reccomended above... is what I thought and was playing with the past couple days. However, I was corrected and also looked at GD.pm only to find there is no newFromJpegData, also, it seems that it only wants a file handle.

      If you check under my nodes, there is several replies when I was working on trying to figure out the newFromJpegData problem.

      --- Scott