0

I have normal and distorted images in project. I need to correctly resize only distorted images

How can I check if image is distorted or not with imagick? Is there any imagick properties which can help me?

Distorted image examples:

enter image description here enter image description here

Neil
  • 14,063
  • 3
  • 30
  • 51
Efim Bistrov
  • 47
  • 1
  • 2
  • 10
  • How do you define a distorted image? – Danack Apr 06 '17 at 13:30
  • Distorted images was made by some code that changed original images. Maybe distorted images was made by changing orientation: http://stackoverflow.com/questions/19456036/detect-exif-orientation-and-rotate-image-using-imagemagick (i used code from second answer to get correct image orientation) – Efim Bistrov Apr 06 '17 at 13:44
  • Images was defined like this: $imagick = new \Imagick(BASE_PATH . '/uploads' . $image->filename); $imagick->resizeimage($newWidth, $newHeight, 0.9, TRUE); $imagick->writeimage($absCacheName); – Efim Bistrov Apr 06 '17 at 13:49
  • How do define a distorted image compared to an image that has just had its orientation corrected? (*hint* - I'm not asking this just to be annoying, your original question isn't answerable without defining this.) – Danack Apr 06 '17 at 13:50

1 Answers1

1

The method signature is: Imagick::resizeImage ( int $columns , int $rows , int $filter , float $blur [, bool $bestfit = false ] )

You are missing the filter parameter, as so the image is being resized without preserving the aspect ratio.

Try passing in \Imagick::FILTER_LANCZOS as the filter parameter.

Danack
  • 24,939
  • 16
  • 90
  • 122
  • Ok, i got it. But question is a little bit different. If i have a lot of images already resized and some images incorrectly resized, can i detect which images was resized correctly, and which not? I need this check to resize back only distorted, incorrect images, not all images. – Efim Bistrov Apr 06 '17 at 14:07
  • "can i detect which images was resized correctly, and which not?" - probably not, not unless you can define what distorted means. If it's just your code that's mangled the images, I suggest just figuring out by hand which images that applies to. I don't believe Imagick stores flags for whether images have been resized in images. – Danack Apr 06 '17 at 14:17