-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Picture is not cropped even though crop: true
is set
#1279
Comments
robinboening
changed the title
Picture is not cropped even though
Picture is not cropped even though Jul 13, 2017
crop: true
is providedcrop: true
is set
@robinboening any news on this issue? Since 4.0.0.rc1 we do not jsonify |
#1320 is maybe related as well. @robinboening could you please check if the issue is still present with latest |
tvdeyen
added a commit
to tvdeyen/alchemy_cms
that referenced
this issue
Nov 3, 2017
Having empty strings as EssencePicture crop value (`crop_from` or `crop_size`) causes imagemagick to not crop the image but resize only. Fixes AlchemyCMS#1279
Merged
Confirmed and fixed by #1321 |
Thanks for working on this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The cropping behaviour is broken. I think its broken in more than just one way, but in this issue I will keep it simple and focus on this one behaviour.
You can reproduce it this way:
Upload a image with a dimension of 800x600. (https://reimann.reisen/wp-content/uploads/2017/02/reimann-reisen-potsdam-image009-800x600.jpg)
Assign the picture in an element with an essence picture.
Render the picture in the view with a certain size and cropping set to true.
I expect the picture to be cropped to exactly 400x400 pixel from the center because I put
crop: true
in there and no manual cropping happened in the UI.What I see instead is a picture that is not cropped at all. Its scaled down to 400x300 pixel.
Technical explanation of the issue:
It seems this issue was introduced with this PR #1084 when the way of using the picture rendering was changed.
Since we merged it in September 2016 we use
picture.url
instead of the url helpers. That is totally fine. Since then thecrop_from
andcrop_size
options are always set in the options hash. This is totally fine as well. If no manual cropping happened in the UI the values of these two options should to be nil (as defined as the default values in thecrop
method here https://github.com/AlchemyCMS/alchemy_cms/blob/master/app/models/alchemy/picture/transformations.rb#L45) - and this is not true. These values are empty strings instead of nil. This leads to the situation that even if we actually have nocrop_from
norcrop_size
it will set the cropping dimensions with0x0+0+0
.This leads to the fact that this picture won't be cropped at all but scaled down to 400x300 pixel.
I will provide a failing test to demonstrate it and a fix as well.
The text was updated successfully, but these errors were encountered: