newbie question: converting images

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
nemephis

newbie question: converting images

Post by nemephis »

Hi there!

I'm new to ImageMagick and I can't get it to work but I need it to convert images into CMYK images for use in PDF's.
I've searched this forum and other websites but their suggestions don't work. I'm probably doing something wrong but I dunno what...

Version: ImageMagick 6.2.8 04/17/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
is what the Red Hat Linux server tells me so I thought everything is ready to go.

In PHP-script I got these lines:

Code: Select all

$input = "rose.jpg";
$output = "testmap/roos.gif";
exec("convert $input $output");
When I go to the script in the browser nothing happens: No error but also no output-img - just a blank page...

Please tell me, what am I doing wrong?
thnx in advance and excuses for my poor english
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: newbie question: converting images

Post by fmw42 »

nemephis wrote:Hi there!

I'm new to ImageMagick and I can't get it to work but I need it to convert images into CMYK images for use in PDF's.
I've searched this forum and other websites but their suggestions don't work. I'm probably doing something wrong but I dunno what...

Version: ImageMagick 6.2.8 04/17/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
is what the Red Hat Linux server tells me so I thought everything is ready to go.

In PHP-script I got these lines:

Code: Select all

$input = "rose.jpg";
$output = "testmap/roos.gif";
exec("convert $input $output");
When I go to the script in the browser nothing happens: No error but also no output-img - just a blank page...

Please tell me, what am I doing wrong?
thnx in advance and excuses for my poor english
I am not a PHP expert, perhaps Bonzo can help you more here. But I am not sure your exec command is complete enough. Check the PHP web site for the full syntax of exec. Also you probably need to give it the correct path to where you have IM installed. Also try converting your output to the same directory as the input (your default directory) and see if that works.

Here is my syntax for using exec. See if this simple command returns your im version.

<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: newbie question: converting images

Post by Bonzo »

nemephis code should work as is but as Fred says you may need the path to convert. I can just use convert but you may need something like /user/local/bin/convert run this and it should tell you the path to convert:

Code: Select all

<?php
system("type convert"); 
?> 
Are you running php as a localhost ? If so you will need to CHMOD your folder for the new image to 777

To get more information on any errors try this:

Code: Select all

<?php
$input = "rose.jpg";
$output = "testmap/roos.gif";
$array=array();
echo "<pre>";
exec("convert $input $output 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?>
nemephis

Re: newbie question: converting images

Post by nemephis »

Thanks for your reaction guys !

It turned out to be a rights-issue: Admin just changed rights on the server and now everything works like a charm: Great!!!! :D
Post Reply