Skip to content
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

Nocrop with resize no longer working #161

Open
mikestead opened this issue Nov 10, 2017 · 8 comments
Open

Nocrop with resize no longer working #161

mikestead opened this issue Nov 10, 2017 · 8 comments

Comments

@mikestead
Copy link

I've recently upgraded from Imaginary 1.0.7 and noticing that the nocrop option isn't working anymore when resizing. Testing via the official docker images this seems to have changed in v1.0.8

nocrop

To get the above results I'm starting the server like so

docker run --rm -p 9000:9000 h2non/imaginary:1.0.7 -enable-url-source

or

docker run --rm -p 9000:9000 h2non/imaginary:1.0.8 -enable-url-source

before running

https://localhost:9000/resize?width=200&height=200&nocrop=true&url=https://c1.staticflickr.com/1/409/18186063494_386acbe85c_k.jpg

@h2non
Copy link
Owner

h2non commented Nov 10, 2017

Nothing relevant changed in imaginary, so I guess this is a behavioral change in bimg. Would need to investigate this.

@mikestead
Copy link
Author

@h2non I've had a look into this and think I've traced the regression in bimg back to a change here

https://github.com/h2non/bimg/blob/master/resizer.go#L456

Currently it's

factor = math.Min(xfactor, yfactor)

Previously it was

if o.Crop {
  factor = math.Min(xfactor, yfactor)
} else {
  factor = math.Max(xfactor, yfactor)
}

If i revert this change then things seem to work again, but I get one failing test in TestResizeVerticalImage stating "shrinkh: image has shrunk to nothing"

I was going to open a PR but worried I'm not fully over this so could be introducing a different regression. Let me know if you want that PR, otherwise hopefully this is of some use.

@h2non
Copy link
Owner

h2non commented Nov 14, 2017

I would prefer maintaining the current behavior since it's more predictable and fits better in the majority of use cases. That being said, you can get similar outputs by playing with force=true|false and embed=true|false params.

@claws-se
Copy link

I have tested changing the "force" and "embed" parameters but that does not seem to solve this. I also tried the new "fit" operation which seemed like it might do a similar thing but that does not seem to help with padding out the image.

@gwildu
Copy link

gwildu commented Mar 6, 2018

@hnon There are definitely usecases where you are in the need of the returned image's dimension to fit what you requested for with and height and the aspect ratio is not changed I would call it inner fit with paddings added.

Currently I'm also unable to get such a behavior on any endpoint as far as I can see

Maybe a new endpoint would be an option? E.g., fill or pad At least then it would be obvious what to expect.

On the other hand I also thought that maybe embed / extend would offer something into that direction, but couldn't figure out how to get those working...

@h2non
Copy link
Owner

h2non commented Mar 6, 2018

Folks, feel free to investigate and provide a fix for this and I will review it asap.
Honestly, I'm pretty busy and I don't have enough motivation for spending my free time fixing issues.

@luphaz
Copy link

luphaz commented Mar 8, 2018

Hi @h2non I would be happy to provide a fix, or an evolution, I would just like to do it as it make the more sense on the both repository (that both belong to you if I'm correct :) ).

For me, the change in bimg make the imaginary parameter extend useless (at least I was not able to find out how to replicate a similar behaviour, "the edges of an image are extended")

I see several options here in order to get this behaviour back :

Main question for me is, as bimg aims to provide a wrapper around vips it make more sense for me to create a fix inside bimg in order to provide to every consumer the ability to use this behaviour (not only imaginary).

Let me know if I should create an issue into bimg as this seems mostly related to a change done there, not inside the imaginary repository.

Let me think what are your thoughts on that @mikestead @claws-se @h2non

@haf
Copy link

haf commented May 4, 2018

@luphaz Hi there

Main question for me is, as bimg aims to provide a wrapper around vips it make more sense for me to create a fix inside bimg in order to provide to every consumer the ability to use this behaviour (not only imaginary).

Me and @claws-se are sitting here and are in agreement that it would be a good idea to open the issue on bimg; but a fix that's local to imaginary would for our purposes just as fine! The biggest problem for us is that we can't upgrade to the latest and greatest.

luphaz pushed a commit to ricardo-ch/bimg that referenced this issue Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants