Converting images without Image::Magick

Discussion in 'Perl Misc' started by Jason Carlton, Nov 17, 2009.

  1. 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?
    Jason Carlton, Nov 17, 2009
    #1
    1. Advertising

  2. 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
    Oliver 'ojo' Bedford, Nov 17, 2009
    #2
    1. Advertising

  3. On Nov 17, 4:15 am, Oliver 'ojo' Bedford <> wrote:
    > 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


    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"); }
    Jason Carlton, Nov 17, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric McDaniel

    Image::Magick and Tk::Photo

    Eric McDaniel, Aug 30, 2003, in forum: Perl
    Replies:
    2
    Views:
    1,579
    Joseph Brenner
    Sep 20, 2003
  2. Weapons of Mass Destruction

    Trying to get Image::Magick to work on a remote server

    Weapons of Mass Destruction, Nov 15, 2003, in forum: Perl
    Replies:
    3
    Views:
    529
    Gunnar Hjalmarsson
    Nov 15, 2003
  3. Tommy Butler

    Image::Magick "geometry" atribute ??

    Tommy Butler, Jul 20, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    165
  4. Rob Bell
    Replies:
    4
    Views:
    205
    Martien Verbruggen
    Sep 10, 2003
  5. Jack
    Replies:
    2
    Views:
    203
    John W. Krahn
    Jan 25, 2008
Loading...

Share This Page