Name
gif( ) — return the image in GIF format
Synopsis
GD::Image::gif
The gif( ) method will convert an image into the GIF format and return it. If your platform makes a distinction between text files and binary files, make sure that you are writing in binary mode by calling binmode( ) first. You can then write the image to the previously opened file:
open OUTFILE, ">beatniks.gif"; # Open the file for writing binmode OUTFILE; # Make sure we're in binary mode print OUTFILE $image->gif; # Print GIF data to the file close OUTFILE;
On Unix systems, you can pipe the image data to an image viewer, such as xv or the display utility that comes with ImageMagick:
open (DISPLAY, "| display ") || # Of course, you must have already die "Couldn't display image!"; # installed display on your system binmode DISPLAY; print DISPLAY $gif_data->gif; # Pipe GIF data to image viewer close DISPLAY; # Close the pipe
Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.