Page 1 of 1

What is the equivalent of this command line?

Posted: 2008-11-14T06:37:52-07:00
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

Re: What is the equivalent of this command line?

Posted: 2008-11-14T10:42:45-07:00
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

Re: What is the equivalent of this command line?

Posted: 2008-11-15T08:25:23-07:00
by tagada_tagada
Thanks but if the command-line exists it must have an equivalent in Perl?
I search but I have no idea :(

Re: What is the equivalent of this command line?

Posted: 2008-11-15T09:52:17-07:00
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