Converting images without Image::Magick

J

Jason Carlton

Like so many others, I can't get Image::Magick to install on my
server. I found where someone had posted (in 2007) that you can first
install graphviz RPM, then the module IPC-Run, then the module
GraphViz, and THEN you might be able to install Image::Magick, but
that's a lot of work if there's an easier way around my problem.

All that I'm using it for is to convert BMP, GIF, and PNG files to
JPG. Is there another way to do this? I've been using Imager; I don't
suppose that you can convert an image with that module, can you?
 
O

Oliver 'ojo' Bedford

Am Tue, 17 Nov 2009 00:39:01 -0800 schrieb Jason Carlton:
All that I'm using it for is to convert BMP, GIF, and PNG files to JPG.
Is there another way to do this? I've been using Imager; I don't suppose
that you can convert an image with that module, can you?

From the man page Imager::Files:
The "type" parameter is a lowercase representation of the file type,
and can be any of the following:

bmp Windows BitMaP (BMP)
gif Graphics Interchange Format (GIF)
jpeg JPEG/JFIF
png Portable Network Graphics (PNG)
pnm Portable aNyMap (PNM)
raw Raw
sgi SGI .rgb files
tga TARGA
tiff Tagged Image File Format (TIFF)

Oliver
 
J

Jason Carlton

Am Tue, 17 Nov 2009 00:39:01 -0800 schrieb Jason Carlton:


  From the man page Imager::Files:
      The "type" parameter is a lowercase representation of the file type,
       and can be any of the following:

         bmp   Windows BitMaP (BMP)
         gif   Graphics Interchange Format (GIF)
         jpeg  JPEG/JFIF
         png   Portable Network Graphics (PNG)
         pnm   Portable aNyMap (PNM)
         raw   Raw
         sgi   SGI .rgb files
         tga   TARGA
         tiff  Tagged Image File Format (TIFF)

  Oliver

I had read that, but just thought it meant that these were the file
types that it would recognize. I didn't see it say anything about
converting.

Can I simply do this:

use Imager;

$path = "/home/mydomain/www/images"
$pic = "leapord.bmp";

my $image = Imager->new;

# Read original $pic
$image->read(file => "$path/$pic");

# Resize to width=300, height proportionate
$resize_pic = $image->scale(xpixels=>300, qtype => 'mixing');

# Write as .jpg
$resize_pic->write(file => "$path/$filename.jpg");

# I'm assuming that writing it with a different name will leave the
original
# image on the server, so it needs to be deleted
if (lc($ext) ne "jpg") { unlink("$path/$filename.$ext"); }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top