-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
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
Feature Request: Add Adaptive Resizing #11
Comments
I managed to make this work by roughly replacing this line with the following code: $currentRatio = $imageAdapter->getOriginalWidth() / $imageAdapter->getOriginalHeight();
$targetRatio = $this->width / $this->height;
if ($targetRatio > $currentRatio) {
$imageAdapter->resize($this->width, null);
} else {
$imageAdapter->resize(null, $this->height);
}
$diffWidth = $imageAdapter->getOriginalWidth() - $this->width;
$diffHeight = $imageAdapter->getOriginalHeight() - $this->height;
$imageAdapter->crop(
floor($diffHeight * 0.5),
floor(($diffWidth / 2) * 1),
ceil(($diffWidth / 2) * 1),
ceil($diffHeight * 0.5)
); Hopefully it can help. |
Hi @jahvi Thanks for the suggestion. To be honest, I do not think that we will add this feature soon as we do not need it for now. However, if you feel like investing time on it, we'd glad to receive a PR and merge it into the module. |
https://github.com/trive-digital/AdaptiveResizeM2/blob/master/Model/Product/Image.php#L66-L80 I have installed this extension.But it is not working. 1.$this->helper('Trive\AdaptiveResize\Helper\Image')->init($_product)->adaptiveResize(240,300); I do not know from where to make call to this helper class. |
Great extension, I was wondering if you could integrate adaptive resizing into it (similar to this other extension) it's probably out of scope but I find it very useful.
As I can see this is the part of the code that handles the resizing but I haven't been able to integrate into this extension:
https://github.com/trive-digital/AdaptiveResizeM2/blob/master/Model/Product/Image.php#L66-L80
The text was updated successfully, but these errors were encountered: