Page 1 of 2
imagemagick installed or not ? I don't understand
Posted: 2008-01-24T09:34:44-07:00
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
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T10:27:33-07:00
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.
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T10:40:17-07:00
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
(((
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T10:45:36-07:00
by Bonzo
ImageMagick is an external program and will not show up in php.ini
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T10:54:54-07:00
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?
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T10:58:16-07:00
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.
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T11:08:32-07:00
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
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T11:16:14-07:00
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);
?>
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T11:54:51-07:00
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");
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T12:07:28-07:00
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
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T12:20:22-07:00
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\">";
?>
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T12:29:38-07:00
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
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T12:35:33-07:00
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>";
?>
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T13:41:25-07:00
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'.
Re: imagemagick installed or not ? I don't understand
Posted: 2008-01-24T14:38:23-07:00
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>";
?>