perl equivalent to "convert image.pdf image.jpg"

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
matthewst

perl equivalent to "convert image.pdf image.jpg"

Post by matthewst »

I can't make imagemagick work in php so maybe perl can do it?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: perl equivalent to "convert image.pdf image.jpg"

Post by Bonzo »

You will need to look at Perlmagick - I know nothing about it but it needs some Perl code installed on the server.
There is a PerlMagick section on the forum along with some examples here http://www.imagemagick.org/script/perl-magick.php

It is probably similar to MagickWand ?
matthewst

Re: perl equivalent to "convert image.pdf image.jpg"

Post by matthewst »

Heres the funny thing, I can run the following script from the web but it still won't convert but it does display "hello world".

test1.pl

Code: Select all

#!/usr/bin/perl
exec "convert image.pdf image.jpg";
print "hello world";
If I'm on the server I can type "perl test1.pl" and it will do what I want it to do.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: perl equivalent to "convert image.pdf image.jpg"

Post by Bonzo »

If you look on the index page of my site near the bottom I have some Perl scripts and there outputs I have "borrowed" from other sites. See if they work?

It does not work like php you need to use an API ?
matthewst

Re: perl equivalent to "convert image.pdf image.jpg"

Post by matthewst »

whats an api?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: perl equivalent to "convert image.pdf image.jpg"

Post by Bonzo »

API = Application programming interface ( http://en.wikipedia.org/wiki/Applicatio ... _interface )

I think basicly its another language to run the first language and supposedly simplify it :?

From what I understand MagicWand, PerlMagic are API's along with things like the one used to produce googlemaps.
ridera

Re: perl equivalent to "convert image.pdf image.jpg"

Post by ridera »

I've started using Imagick, a new PHP native extension.

CardinalRules.pdf just happened to be a pdf I had handy. Obviously, it has to be in the same directory, or you must include the full path. AND, the dir must have write permissions if you use the write file version.

This works if you need other html stuff on the page:

Code: Select all

$report= "<html><body>\n\n";

$obj = new Imagick('CardinalRules.pdf'); 
$obj->SetImageFormat('jpeg');
$obj->writeImage('CardinalRules.jpg');

$report .= "<img alt=\"image missing\" src=\"./CardinalRules.jpg\">\n\n";
$report .= "</body></html>\n\n";

echo $report;
Alternatively, you can send the jpg to the client and not make a file.

Code: Select all

header('Content-type: image/jpeg');
$obj = new Imagick('CardinalRules.pdf'); 
$obj->SetImageFormat('jpeg');
echo $obj;
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: perl equivalent to "convert image.pdf image.jpg"

Post by anthony »

For basic command line OR API tests in PHP see..
http://www.imagemagick.org/Usage/api/#php

This is always a good place to start for any new Web server, so you can find out what is and is not installed and working on that web server. Especially when you did not install it and don't have system level access.

They are also good tests to use in reports to ISP's to get them to fix there web server, and not so complex it takes a lot to know what they are doing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply