Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Issue when resizing (not whole height) #15

Open
luclaurent opened this issue Oct 13, 2014 · 2 comments
Open

Issue when resizing (not whole height) #15

luclaurent opened this issue Oct 13, 2014 · 2 comments

Comments

@luclaurent
Copy link

I am trying to use the "crop" script on my website for generating thumbnails of panoramic pictures. I observe a very strange result (but maybe normal) when I use "CropEntropy". My goal is to extract a thumbnail with random size for many pictures (for building a mosaic).

My approach is:

  1. I resize (if necessary) my pictures using Imagick (I specify a maximum width of height of 4000px because panoramic pictures are really huge). These pictures can be consider as reference pictures.
  2. I resize these pictures for generating thumbnails using Imagick (maximum height=400px).
  3. I use the "CropEntropy" function on the 400px pictures for extracting thumbnails using a box that I have computed the size (the height of the thumbnail will be equal to H=0.7*400 and the width (W) will be randomly chosen between two values (400 and 1000px in my case)).

For the third point, I use the following syntax (where $image is the 400px picture):
$cropperEntropy = new stojg\crop\CropEntropy($image);
$croppedImage = $cropperEntropy->resizeAndCrop(intval($DimCropWidth),intval($DimCropHeight));
$croppedImage->writeimage($ImageNameCrop);

Using this process, I obtain a HxW picture (height H, width W) but the function resize the original 400px-picture for obtaining a picture with a height of H. Maybe this issue is normal but in my case, I have commented the line "$this->originalImage->resizeImage($crop['width'], $crop['height'], \Imagick::FILTER_CUBIC, .5);" in the Crop.php file for avoiding this and obtaining crop picture with not the whole height of my orginal picture.

I don't know if I am very clear but maybe it can be interresting to correct this issue (if it is one) or adding the possibility of extracting one box inside of a picture (with not the whole height of the original picture).

The issue seems to come from the "getSafeResizeOffset" function that fixes the cropping height to $targetHeight in my case.

@ecaron
Copy link
Collaborator

ecaron commented Nov 4, 2014

I took a swing at this tonight, but couldn't make much progress. Could you supply a fully functional code to reproduce what you're talking about, as well as a sample image? I think that'll be the most direct way to ensure we're all on the same page.

@stojg
Copy link
Owner

stojg commented Feb 12, 2016

Example images, source and the failing result would be helpful :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants