What is the equivalent of this command line?

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
tagada_tagada

What is the equivalent of this command line?

Post by tagada_tagada »

Hello,

I need the equivalent of the command-line:

Code: Select all

convert -geometry 1280x1024 -density 300x300 -quality 100 myfile.pdf myimage.jpeg
but I can not get a good image quality output as command line when I use perl

I try this in perl:

Code: Select all

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

# Create an image
my $im = Image::Magick->new();
$im->Read('myfile.pdf');
$im->Resize(geometry=>'1280x1024',width=> '1280', height=>'1024') ;
$im->Write(filename => 'myimage.jpg', density => '300x300', quality => 100);
Would you have an idea?

Thank you
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: What is the equivalent of this command line?

Post by el_supremo »

In your command line example the geometry, density and quality are specified before the PDF file is read. But in your Perl example you don't specify them until you write the file. I don't know how to do this in Perl but you need to specify them before you read the PDF.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
tagada_tagada

Re: What is the equivalent of this command line?

Post by tagada_tagada »

Thanks but if the command-line exists it must have an equivalent in Perl?
I search but I have no idea :(
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: What is the equivalent of this command line?

Post by el_supremo »

I think you may only need to specify the density first. The quality applies to the JPG so you probably have that in the right place.

Try this:

Code: Select all

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

# Create an image
my $im = Image::Magick->new();
$im->Set(density=>'300x300');
$im->Read('myfile.pdf');
$im->Resize(geometry=>'1280x1024',width=> '1280', height=>'1024') ;
$im->Write(filename => 'myimage.jpg',quality => 100);
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Post Reply