We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to resize image with 2000x1100 dimensions to 1350x1290 without visual deffects. So, i write this code:
$resizedImageObject = Image::resize($originalImageSrc, $newWidth, $newHeight, false, true);
Original image:
My image will resize to 2346x1290 and than crop left and right side, so i expected to get:
My image was compressed in width and sctretched in height. So, I get:
I solved this with this code:
$originalImageObject = Image::getImagine()->open($originalImageSrc); $originalImageSizeObject = $originalImageObject->getSize(); $originalImageWidth = $originalImageSizeObject->getWidth(); $originalImageHeight = $originalImageSizeObject->getHeight(); $resizedImageWidth = ($newWidth / $newHeight < $originalImageWidth / $originalImageHeight) ? null : $newWidth; $resizedImageHeight = ($newWidth / $newHeight > $originalImageWidth / $originalImageHeight) ? null : $newHeight; $resizedImageObject = Image::resize($originalImageSrc, $resizedImageWidth, $resizedImageHeight, false, true); $resizedImageSizeObject = $resizedImageObject->getSize(); $resizedImageWidth = $resizedImageSizeObject->getWidth(); $resizedImageHeight = $resizedImageSizeObject->getHeight(); $cropImagePointX = ($resizedImageWidth - $newWidth) / 2; $cropImagePointY = ($resizedImageHeight - $newHeight) / 2; $pointForCenterCropImage = new Point($cropImagePointX, $cropImagePointY); $boxForCenterCropImage = new Box($newWidth, $newHeight); $resizedImageObject->crop($pointForCenterCropImage, $boxForCenterCropImage);
This feature helps to resize image without visual deffects, to my mind it would be great to implement it in future updates, what do think about it?
The text was updated successfully, but these errors were encountered:
$resizedImageObject = Image::thumbnail($originalImageSrc, $newWidth, $newHeight);
thumbnail method is for doing what you need. resize was added later to do exactly opposite of that. So both usecases are covered AFAIK.
thumbnail
resize
If you think documentaion on it could be improved then some ideas would be helpful.
Sorry, something went wrong.
No branches or pull requests
What steps will reproduce the problem?
I want to resize image with 2000x1100 dimensions to 1350x1290 without visual deffects. So, i write this code:
Original image:

What's expected?
My image will resize to 2346x1290 and than crop left and right side, so i expected to get:

What do you get instead?
My image was compressed in width and sctretched in height. So, I get:

Additional info
I solved this with this code:
This feature helps to resize image without visual deffects, to my mind it would be great to implement it in future updates, what do think about it?
The text was updated successfully, but these errors were encountered: