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

Hi all,
I have this typical requirement on Mac system and I want to use Perl.

1) I have to open Illustrator EPS files in Illustrator and have to save it as JPG at the same location.
2) Open Photoshop EPS in Photoshop and save it to JPG at the same location.
3) TIFF could be opened in any application and save it to JPG.

There are a few extra settings like:
Resolution should be 120 dpi
Trim white edges
Color mode should be RGB

Could anyone guide me on how to do it?

Regards,
Sandeep

Replies are listed 'Best First'.
Re: Image Conversion to JPEG
by sh1tn (Priest) on Oct 26, 2005 at 12:45 UTC
Re: Image Conversion to JPEG
by jesuashok (Curate) on Oct 26, 2005 at 12:48 UTC
    Hi,

    This is possible to be done by using :Image::Magick" module Once you Install this package you can read the manual of this module. The manual comes with the Examples you required.

    For your information I have added this small example.

    > formats to jpg. my($name) = shift; my($img) = Image::Magick->new; if (!($name =~ /.jpg|.JPG/)){ open(IMAGE, $name); # Open the original file $rc = $img->Read(file=>\*IMAGE); # Read the file

    To me, the above two lines are a somewhat cumbersome looking way of reading the file. If you must use a pre-opened file handle, maybe it would be worth figuring it out. One idea, is that if you are on Windows, it might be that you need to use "binmade" on the handle, before passing it it Read, I have no idea if Read does such internally.

    But it sounds to me that you would be just as happy using

    $rc = $mig->Read(filename=>$name);

    instead of the above 2 lines, and then... down below...

    Again there is more than one way of doing things

    "Keep pouring your ideas"

    Code tags added by GrandFather

      Interesting answer, jesuashok.  I wondered why you started your code section with "> formats to jpg.", but then realized that's how part of the the original article at www.imagemagick.org was worded as well:
      > This is the beginning of a subroutine that should convert pictures i +n other > formats to jpg. > > my($name) = shift; > my($img) = Image::Magick->new; > if (!($name =~ /.jpg|.JPG/)){ > > open(IMAGE, $name); # Open the original file > > $rc = $img->Read(file=>\*IMAGE); # Read the file To me, the above two lines are a somewhat cumbersome looking way of reading the file. If you must use a pre-opened file handle, maybe it would be worth figuring it out. One idea, is that if you are on Windows, it might be that you need to use "binmade" on the handle, before passing it it Read, I have no idea if Read does such internally +. But it sounds to me that you would be just as happy using $rc = $mig->Read(filename=>$name); instead of the above 2 lines, and then... down below... > > print $rc; > > close(IMAGE); # Close the original file handle > > my($base, $ext) = split(/\./,$name); # extract the base of + the file > name > > $name = "$base.jpg"; # Add the 'jpg' to the filename > > open(IMAGE, ">$name"); # Open the file for outputting the converted > image > > $rc = $img->Write(file=>\*IMAGE, filename=>"$name"); # Wri +te the image $rc = $img->Write(filename=>$name); instead of the above 2 lines. > print $rc; > > close(IMAGE); # Close the file handle > }

      And what a coincidence that the original author, when he wrote this on November 9, 2004, also thought "the above two lines are a somewhat cumbersome looking way of reading the file.", etc.

      Of course, when he wrote the message, and said "down below...", he then went ahead and provided more code.  Your message kind of abruptly ends with "instead of the above 2 lines, and then... down below...", which lacks a certain sense of closure, I think.


      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/