Reputation: 1329
So today after snooping around on stackoverflow I found out about imagemagick
and it looks awesome. Keep in mind I just discovered this today and I've been messing around trying to get it work for me for a couple hours but to no avail, so I could really use some guidance.
I asked my hosting company and I checked the terminal and I do have it.
Through PuTTY I ran:
whereis convert
Which spit me out:
convert: /usr/bin/convert /usr/share/man/man1/convert.1.gz
And then to double check:
/usr/bin/convert --version
Which gave me:
Version: ImageMagick 6.7.2-7 2015-07-29 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: Open MP
So in my public_html I created a file called test.php in which I put:
<?php
try
{
$cmd = "public_html/account/archives/emails/2015/November-Email.pdf";
exec("usr/bin/convert $cmd");
}
catch(Exception $e)
{
die('Error when creating a file: ' . $e->getMessage());
}
?>
When I run test.php
it just shows a blank screen so clearly somethings wrong as not even the Error message is showing.
Upvotes: 1
Views: 694
Reputation: 5299
You do not have an output file name. exec() will not display anything but system() will in certain circumstances
exec("/usr/bin/convert -version ) will not display anything system("/usr/bin/convert -version ) SHOULD display the version
You may be able to just use convert depending on your setup.
The path to your image can be relative.
You will probably want to add a density to the command to control the pdf quality.
Give this a try:
<?php
$array=array();
echo "<pre>";
$cmd = "public/html/account/archives/emails/2015/November-Email.pdf";
exec("usr/bin/convert -density 300 $cmd output.jpg 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
?>
Upvotes: 1