Jacob,
Yes I've used imagemagick with php.  I found that none of the online
documentation worked for me.  I was unable to use the imagemagick class and
the tutorials seemed to refer to older versions.

That being said, here's some code that does work, maybe you can extrapolate
from it.
Feel free to contact me if you have questions.

<snipet>
/*** rename the file.
* Note: I've got a form that supports multiple file uploads, hence the
$_FILES array
* the renameFile() function creates a unique file name for the image being
uploaded
* so no existing files are overwritten
*/
$photo_name = renameFile($_FILES["photo"]["name"][$i],0);
$photo_location = "/www/gallery/photos/";
// copy file from /tmp to photos/tmp
copy ($_FILES["photo"]["tmp_name"][$i],$photo_location.$photo_name);
$command = "/usr/bin/identify -verbose '".$photo_location.$photo_name."'";
exec ($command,$result,$value);
</snipet>

<snipet>
/*** get verbose information
* in the rename code above $command contains the 'verbose' information from
imagemagick
*/
$arrlength = count($result);
for ($tmpi = 0; $tmpi < $arrlength; $tmpi++)
{
        if(eregi('Geometry', $result[$tmpi]))
        {
        $tmp1 = explode(' ', $result[$tmpi]);
                $tmp1length = count ($tmp1);
                for ($tmpj = 0; $tmpj < $tmp1length; $tmpj++)
                {
                        $tmp2 = explode('x', $tmp1[$tmpj]);
                        $tmp2length = count ($tmp2);
                        if ($tmp2length > 1)
                        {
                                $x = $tmp2[0];  // this is the image width
                                $y = $tmp2[1];  // this is the image height
                        }
                }
        }
}
</snipet>

<snipet>
/***
* the following code takes the dimensions of the image, and if the image is
too big,
* resizes  the image down to the max image size.
*/
if ($x > $image_max_width || $y > $image_max_height)// resize photo to max
dimensions
{
        $x = $image_max_width;
        $y = $image_max_height;
        $command = "/usr/bin/convert -geometry ". $x ."x". $y ."
".$photo_location.$photo_name ." ".$photo_location.$photo_name;
        exec ($command,$result,$value);
}
</snipet>

I know you can do compositing with Imagemagick, but I haven't tried that.  I
assume it's as complex as everything else with Imagemagick.  Imagemagick is
a pain, but the quality of the resized images so far surpasses GD(2) that
it's worth the work.
Good luck.
Chris

-----Original Message-----
From: Jacob Marble [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 09, 2003 1:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Imagick


Excuse me, I accidentally sent that last incomplete message.
I have successfully compiled PHP 4.3.3RC3 with the --with-imagick flag after
compiling and installing ImageMagick 5.5.7 (that was a headache on it's
own).  The following error keeps cropping up:

Fatal error: Call to undefined function: imagick_readimage() in
/usr/local/lib/php/docs/imagick/examples/border.php on line 5

I've tried compiling PHP without the --with-imagick flag and then doing a
"pear install imagick" to get the pear version 0.9.7 package.  The same
problem occurs.  I don't even know how to use imagick yet; I can't get the
thing to work with example files, so I can't start writing my own stuff yet.
Does anyone at this NG use the imagick tools?  Is there something I have to
include maybe?  Like "require 'imagick.php'" or something?  I can't find any
files that look appropriate for that.

Thanks in advance,

Jake

LandEZ



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to