imagemagick installed or not ? I don't understand

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?".
Ven

imagemagick installed or not ? I don't understand

Post by Ven »

I've installed ImageMagick, so if i run this code....

Code: Select all

<?php
echo "<pre>";
system("convert -version");  
echo "</pre>";
?> 

...i have the correct output. But if i check my phpinfo i'm not able to find ImageMagick. For example if i run this code...

Code: Select all

<?php

header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

?> 
...php doesn't show any image.

What's the problem :( :( :(
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

ImageMagick is an external program and will not show up in php.ini

Imagick is an API for ImageMagick ( notice the different names - seems to cause confusion ). Imagick needs ImageMagick to work.

So to get your code to work you need to install Imagick as well or do as I do and use the exec( ) function of php.
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

I installed ImageMagick from this guide http://www.smudge-it.co.uk/pub/imagemag ... ource.html

but i don't know why i don't see it in Phpinfo :((((
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

ImageMagick is an external program and will not show up in php.ini
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

I've a php script that wants Imagemagick installed on the webserver. What i must do ? I'm a newbie :(((((


i run this command

echo "extension imagick.so" > /etc/php.d/imagick.ini

isn't correct?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

Did you read my first post ?

You have ImageMagick installed but you are trying to run an Imagick script - They are not the same thing. You need to install Imagick to run the script.
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

Bonzo wrote:Did you read my first post ?

You have ImageMagick installed but you are trying to run an Imagick script - They are not the same thing. You need to install Imagick to run the script.
That's a sample script.

My script ask me where is installed ImageMagick "/usr/local/bin/convert"

If i run your code...

Code: Select all

<?php
echo "<pre>";
system("type convert"); 
echo "</pre>";
?> 
...it says that it's installed correclt at "/usr/local/bin/convert"


So i think it's not necessary installing Imagick, right ? Sorry but my english is not very good :)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

This is an IMAGICK script to resize an image and needs IMAGEMAGICK an IMAGICK installed:

Code: Select all

<?php

header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

?> 
I do not know if this is resizing and saving the image as I do not use IMAGICK

This is an IMAGEMAGICK script using the command line to resize and save an image:

Code: Select all

exec("/usr/local/bin/convert image.jpg -resize 100x100 output.jpg");
This is an IMAGEMAGICK script using the command line to resize and display an image without saving it:

Code: Select all

<?php
header("Content-type: image/jpeg");
passthru("/usr/local/bin/convert image -resize 100x100 JPG:-", $retval);
?>
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

the webmaster of the script says it's not necessary install imagick, i'll try your code. thanks


where i must put the image.jpg to run this code ?

Code: Select all

exec("/usr/local/bin/convert image.jpg -resize 100x100 output.jpg");
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

i tried this code found on this forum...

Code: Select all

if (file_exists('image.jpg')) {
echo 'file exists';
}

exec("/usr/local/bin/convert image.jpg image.gif");

if (file_exists('image.gif')) {
echo 'it worked';
} else {
echo 'no you fool, doesnt work';
}

...but i don't have any conversion, i think ImageMagick have some trouble on my server. I check the "bin" directory and the file "convert" exist.

What's the problem :(
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

Put this code in the same directory as image.jpg The directory must be CHMOD to 777 or if you get a 500 error try 755

Code: Select all

<?php
exec("/usr/local/bin/convert image.jpg -resize 100x100 output.jpg");
echo "<img src=\"image.jpg\">";
echo "<img src=\"output.jpg\">";
?>
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

Bonzo wrote:Put this code in the same directory as image.jpg The directory must be CHMOD to 777 or if you get a 500 error try 755

Code: Select all

<?php
exec("/usr/local/bin/convert image.jpg -resize 100x100 output.jpg");
echo "<img src=\"image.jpg\">";
echo "<img src=\"output.jpg\">";
?>
no, output.jpg is not created :(
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

This should display any errors:

Code: Select all

<?php
$array=array();
echo "<pre>";
exec("/usr/local/bin/convert image.jpg -resize 100x100 output.jpg 2>&1", $array); 
echo "<br>".print_r($array)."<br>";
echo "</pre>"; 
?> 
Ven

Re: imagemagick installed or not ? I don't understand

Post by Ven »

I have this output, thanks

Code: Select all

 [0] => convert: no decode delegate for this image format `image.jpg'.
    [1] => convert: missing an image filename `output.jpg'.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: imagemagick installed or not ? I don't understand

Post by Bonzo »

In the output of this code do you have these values?

JPEG* JPEG rw- Joint Photographic Experts Group JFIF format (62)
JPG* JPEG rw- Joint Photographic Experts Group JFIF format

The rw is the important part.

Code: Select all

<?php
echo "<pre>";
system ("convert -list Format");
echo "</pre>";
?>
Post Reply