Jump to content

image magick help


darkfreaks

Recommended Posts

anyone could provide an example on how to compare 2 images in image magick would be greatful.

 

i need it 2  compare and make sure the 2 images are exactly the same image. even if it has been cropped,sharpened,blurred(of any sort),feathered,grey scaled,Rotated,flipped,mirrored.

 

 

im learning image functions in class and would like to impress my professor with such a script.

 

-much appreciated.

 

http://www.imagemagick.org/Usage/

Link to comment
Share on other sites

<?php

$resource =new Imagick();
$image= $_POST['image'];
$image_two= $_POST['image_two'];

$resource->imagick_isimagesequal( $image, $image_two); //line 7
?>

Edit: ok i left out the comma its fxed now but i get "Fatal error: Call to undefined method Imagick::imagick_isimagesequal()"

Link to comment
Share on other sites

ok revamped the code

 

<?php
//image 1
$image= $_POST['image'];
//image 2
$image_two= $_POST['image_two'];
//connection 1
$im1 =new Imagick();
//ping first image
$im->pingImage($image);
//read first image
$im1->readImage($image);
//second connection
$im2 =new Imagick();
//ping second image
$im->pingImage($image_two);
//read second image
$im2->readImage($image_two);
//compare both images
imagick_isimagesequal( $image, $image2); 
?>

 

"can not execute pingImage() on a non object"

 

"can not execute readImage() om a non object"

 

anyone see where im going wrong :confused:

Link to comment
Share on other sites

did some fixing of code my variables werent matching up and were throwing undefined errors which went undetected till i put error_reporting on  8)

 

now the only problem is i keep getting "undefined method Imagick:: imagick_isimagesequal()" on line 21. which is the following line....

 

 // compare connection
  $im = new Imagick();
  //compare both images
  $im->imagick_isimagesequal($image, $image2);

Link to comment
Share on other sites

im making progress i just need help with  connecting both $im1 and $im2 to the compare function :confused:

 

 

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1); 
  //image 1
  $image = $_POST['image'];
  //image 2
  $image_two = $_POST['image_two'];
  //connection 1
  $im1 = new Imagick($image);
  //ping image 1
   $im1->pingImage($image);
   //read image 1
  $im1->readImage($image);
  //second connection
  $im2 = new Imagick($image_two);
  //ping second image
  $im1->pingImage($image_two);
  //read second image
  $im2->readImage($image_two);
  //compare both images (trouble getting it to connect)
imagick_isimagesequal($image,$image2);
?>

Link to comment
Share on other sites

Before anyone asks this yes PECL and Imagick are both enabled and running on my web hosts server.

 

i have fixed my code it all works except this line.

imagick_isimagesequal( $image, $image2); 

 

and i am pretty sure it is throwing an "undefined" error because i have not connected any resources to it. the problem i have is that i can not find an example on how to exactly use this function or how i would connect both image  and image_two to it.

 

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1); 
  //image 1
  $image = $_POST['image'];
  //image 2
  $image_two = $_POST['image_two'];
  //connection 1
  $im1 = new Imagick($image);
  //ping image 1
   $im1->pingImage($image);
   //read image 1
  $im1->readImage($image);
  //second connection
  $im2 = new Imagick($image_two);
  //ping second image
  $im1->pingImage($image_two);
  //read second image
  $im2->readImage($image_two);
  //compare both images (trouble getting it to connect)
imagick_isimagesequal($image,$image_two);//throws undefined error 
?>

Link to comment
Share on other sites

  • 2 weeks later...

according to a regular on the imagick forum i am using a newer version of imagick and the compare function has been deemed obsolete.

 

i am using imagick 2.3.0 .

 

can i use the following imagick functions to achieve what i need?

 

Function Parameters                          Description

CompareLayers  method=>{any, clear, overlay}  compares each image with the next in a sequence and returns the minimum bounding region of any pixel differences it discovers. Images do not have to be the same size, though it is best that all the images are coalesced (images are all the same size, on a flattened canvas, so as to represent exactly how a specific frame should look).

 

 

Layers    method=>{coalesce, compare-any, compare-clear, compare-over, composite, dispose, flatten, merge, mosaic, optimize, optimize-image, optimize-plus, optimize-trans, remove-dups, remove-zero}, compose=>{Undefined, Add, Atop, Blend, Bumpmap, Clear, ColorBurn, ColorDodge, Colorize, CopyBlack, CopyBlue, CopyCMYK, Cyan, CopyGreen, Copy, CopyMagenta, CopyOpacity, CopyRed, RGB, CopyYellow, Darken, Dst, Difference, Displace, Dissolve, DstAtop, DstIn, DstOut, DstOver, Dst, Exclusion, HardLight, Hue, In, Lighten, LinearLight, Luminize, Minus, Modulate, Multiply, None, Out, Overlay, Over, Plus, ReplaceCompositeOp, Saturate, Screen, SoftLight, Src, SrcAtop, SrcIn, SrcOut, SrcOver, Src, Subtract, Threshold, Xor }, dither=>{true, false}

 

compare each image the GIF disposed forms of the previous image in the sequence. From this, attempt to select the smallest cropped image to replace each frame, while preserving the results of the animation.

 

 

 

http://www.imagemagick.org/script/perl-magick.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.