Compare comand and docs

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Groo

Compare comand and docs

Post by Groo »

Hi,
I have been using ImageMagick from command line for some days... Now I want to do what I have tested in php using IMagick.

I have read that full documentation will be ready soon, but, for now, http://php.net/imagick documentation is really very very poor (especially for people like me that aren't php professionals), even I think that the only two examples shown are wrong (you have to use readimage()). so, when full doc will be aviable? Is any possible to access what is done for now?

In other way I need two compare groups of images, in command line I use "compare" command, I think that similar command in IMagick is compareImageChannels (http://www.php.net/manual/en/function.i ... annels.php) so I tried to use this with no results. I am doing somethning wrong for sure. Any help would be really appreciated:

Code: Select all

$im = new Imagick();
$im->readimage('image.jpg');

#Modified Image:

$im_ref = new Imagick();
$im_ref->readimage('image2.jpg');

$result = $im->compareImageChannels($im_ref,imagick::CHANNEL_ALL,imagick::METRIC_MEANABSOLUTEERROR);

var_dump($resultado);
I get:

Catchable fatal error: Argument 3 passed to Imagick::compareimagechannels() must be an instance of Imagick, integer given in /home/groo/compara2/informe.php on line 36

Thanks a Lot.
Groo.
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: Compare comand and docs

Post by mkoppanen »

Groo wrote:Hi,
I have been using ImageMagick from command line for some days... Now I want to do what I have tested in php using IMagick.

I have read that full documentation will be ready soon, but, for now, http://php.net/imagick documentation is really very very poor (especially for people like me that aren't php professionals), even I think that the only two examples shown are wrong (you have to use readimage()). so, when full doc will be aviable? Is any possible to access what is done for now?
Feel free to help with the documentation if you find it "very poor". I am currently quite busy and my time with the documentation is limited but I am working on it.

You don't have to use readImage separately. Passing filename(s) as a parameter to constructor was added in the alpha phase but sadly some distros still have only an early alpha version of the imagick package.
Groo wrote: In other way I need two compare groups of images, in command line I use "compare" command, I think that similar command in IMagick is compareImageChannels (http://www.php.net/manual/en/function.i ... annels.php) so I tried to use this with no results. I am doing somethning wrong for sure. Any help would be really appreciated:

Code: Select all

$im = new Imagick();
$im->readimage('image.jpg');

#Modified Image:

$im_ref = new Imagick();
$im_ref->readimage('image2.jpg');

$result = $im->compareImageChannels($im_ref,imagick::CHANNEL_ALL,imagick::METRIC_MEANABSOLUTEERROR);

var_dump($resultado);
I get:

Catchable fatal error: Argument 3 passed to Imagick::compareimagechannels() must be an instance of Imagick, integer given in /home/groo/compara2/informe.php on line 36

Thanks a Lot.
Groo.
This was a bug with argument hinting. I fixed it and committed to the CVS. It will be in the next Imagick release.
Mikko Koppanen
My blog: http://valokuva.org
Groo

Re: Compare comand and docs

Post by Groo »

mkoppanen wrote:
Feel free to help with the documentation if you find it "very poor". I am currently quite busy and my time with the documentation is limited but I am working on it.
Sorry, I don't want to offend you. I think you are doing a great job with Imagick. But for people, like me, that have low kwonledges in OO programming there is a lack of examples and detailed information. Despite, I have found very very useful examples in your blog: (http://valokuva.org/) that is helping me a lot.
mkoppanen wrote: You don't have to use readImage separately. Passing filename(s) as a parameter to constructor was added in the alpha phase but sadly some distros still have only an early alpha version of the imagick package.
Oh, I suppose you are right, I am using Debian testing distro and Imagick version aviable is: 2.0.0-alpha. I nearly get crazy discovery I have to use readImage().
mkoppanen wrote: This was a bug with argument hinting. I fixed it and committed to the CVS. It will be in the next Imagick release.
I am afraid I am not so skilled to use CVS. I will have to wait until next release.

Thanks for your quick answer.
Paco.
Groo

Re: Compare comand and docs

Post by Groo »

Hi again,
I infravalue myself. Finally I get working last CVS version. I unninstalled distribution package (2.0.0alpha) and installed PECL version (2.0.0) after tha I download CVS version, phphize, configure, make and install; and now I am running last 2.0.1-rc1

I tested my original code and works really fine:

Code: Select all

#Original Image:
$im = new Imagick('image.jpg');
#Modified Image:
$im_ref = new Imagick('image2.jpg');
$result = $im->compareImageChannels($im_ref,imagick::CHANNEL_ALL,imagick::METRIC_MEANABSOLUTEERROR);
$result[0]->writeImage('result.jpg');
echo "$result[1] \n";
Output: 1875.30830838

Using: "compare -metric MAE image.jpg image2.jpg result.jpg" from command line I get same results:
1875.31 dB

Excellent :D

Thanks.
Post Reply