View Single Post
  #3 (permalink)  
Old 08-22-2007, 03:06 AM
raj raj is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
raj is on a distinguished road
Post Converting between image formats using perl eg: JPEG to GIF

hi all,

you can change your image format from JPEG to GIF or some other image format:


Changing files from one format to another is quite easy with a little bit of Magick. In the example below a JPG image (test.jpg) is converted into a GIF-image (test.gif). To output in a different (ImageMagick supported) format, just change the "image->Set" line.

#!/usr/bin/perl -w
use strict;
use Image::Magick;

my $image = Image::Magick->new();

# To explicitly set image format use this instead:
# my $image = Image::Magick->new(magick=>'JPEG');

my $x = $image->Read('test.jpg');

$x = $image->Set(magick => 'GIF');
$x = $image->Write('test.gif');

exit();
Reply With Quote