Page 1 of 1

Strange problem with convert

Posted: 2013-09-03T05:08:17-07:00
by dhrubo
Hi,

I'm in a strange problem. I'm trying to export brytum gantt chart in pdf/png.

I'm about to complete the export, but a strange problem i'm facing.

Code: Select all

$imgkOut = array();

                //run imagemagick merging separate png's into one pdf or png depending on the file format
                if ($fileFormat == 'pdf'){
                    $cmd = $imgkPath.'convert '.$pdfs.' "'.$outputPath.'/'.$out.'"';
                } else {
                    $cmd = $imgkPath.'montage -mode concatenate -tile 1x '.$pdfs.' "'.$outputPath.'/'.$out.'"';
                }
                exec($cmd, $imgkOut);

This is one of my code sample.
here, in the exec function command is not executing successfully.

I've got the value of $cmd which is : convert D:\PHP\xampp\htdocs\export/print-1378204549859.png D:\PHP\xampp\htdocs\export/print-1378204550271.png "D:\PHP\xampp\htdocs\export/complete-exportedPanel0.634509001378204542.pdf"

If i run this command from command prompt, then the command is executing successfully, even it is write a block of code in another php file like :

Code: Select all

$imgkOut = array();
$cmd = 'convert D:\PHP\xampp\htdocs\export/print-1378204549859.png D:\PHP\xampp\htdocs\export/print-1378204550271.png  "D:\PHP\xampp\htdocs\export/complete-exportedPanel0.634509001378204542.pdf"';
$imgkOut = exec($cmd);
at this time also the pdf is creating. But bad luckily, in the project, the pdf is not creating.

I've no idea, why this is not working under the project. But i'm getting the same value in $cmd variable.

Please help me someone. This strange problem is ruining my all day long. Sorry for my bad english :)

Thanks
Dhrubo

Re: Strange problem with convert

Posted: 2013-09-03T05:14:51-07:00
by snibgo
What error messages do you get?

What happens when you run that command at the command line?

What version of ImageMagick and what platform?

Re: Strange problem with convert

Posted: 2013-09-03T07:47:15-07:00
by Bonzo
I presume $imgkPath does not already contain convert?
Is there a / between the path and convert?

The $cmd line looks way to complicated - try and keep it simple so you can see what is going on. I would write it like this:

Code: Select all

$output = $outputPath.'/'.$out;
$imgkPath = $imgkPath.'convert';
$cmd = "$imgkPath $pdfs $output";
I see you are using XAMPP and I would have put the pdf's within the localhost folder.

As with everything start off with something simple for example all files and code in the same folder so you know the convert is working and when it works then add all the other code.