darkfreaks Posted April 19, 2010 Share Posted April 19, 2010 im doing a project for a class i need to know how i would compare jpeg/jpg/gif/png images with image magick PHP. if anyone has any links or explanations/examples please feel free to provide them. Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/ Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 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/ Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046537 Share on other sites More sharing options...
litebearer Posted April 22, 2010 Share Posted April 22, 2010 imagick_isimagesequal ( resource image, resource image2 ) Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046573 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 thanks how would i use that in an if statement to return whether or not it returns true or false. Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046576 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 "undefined function imagick_isimagesequal" what is going wrong now? do i have to include image magick files or does my server not support it? Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046588 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 i have a feeling i am not connecting each resource newmagickwand() function but how would i do that? Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046603 Share on other sites More sharing options...
litebearer Posted April 22, 2010 Share Posted April 22, 2010 Might take a look at this forum http://www.imagemagick.org/discourse-server/ Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046614 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 <?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()" Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046619 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046682 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 what could be causing this Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046738 Share on other sites More sharing options...
darkfreaks Posted April 22, 2010 Author Share Posted April 22, 2010 did some fixing of code my variables werent matching up and were throwing undefined errors which went undetected till i put error_reporting on 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); Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046743 Share on other sites More sharing options...
darkfreaks Posted April 23, 2010 Author Share Posted April 23, 2010 im making progress i just need help with connecting both $im1 and $im2 to the compare function <?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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1046756 Share on other sites More sharing options...
darkfreaks Posted April 23, 2010 Author Share Posted April 23, 2010 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1047096 Share on other sites More sharing options...
darkfreaks Posted May 3, 2010 Author Share Posted May 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/199072-image-magick-help/#findComment-1052516 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.