Comments (21)
sorry about that, this is in fact an issue
from vip.
Make up your damn mind
from vip.
@jrit I think we just need to set Enlarge: true
in the Options: https://github.com/DAddYE/vips/blob/master/vips.go#L161-L169
from vip.
It sounds like that would enlarge the image, which we don't want, it just needs to be cropped to the largest square at the current size. Am I misreading?
from vip.
It would, but what would be the difference on a practical level if vip does the resizing versus the browser?
The other solution is to check the size, and if it's already smaller then do the crop using Go's image
library. Alternately, we might get the behavior we want by using https://github.com/h2non/bimg instead of the daddye/vips package we are using. The point is that vips won't do the crop properly without the enlarge the way it is written (I don't think).
from vip.
In other words, setting Enlarge: true
is a trivial solution that can be implemented now while we investigate other options. h2non/bimg is in early beta, of instance, so it might need forking and improving before we could use it.
from vip.
I'm not seeing how Enlarge: true
solves anything to be honest
from vip.
I think the right solution is if c=true
and the image isn't cached, to check the size before the resize occurs, if it is oversized, we can just give vips a smaller size so it will center-crop without scaling. If there is no center-crop, the current code path would be the same.
from vip.
by "no center-crop" I mean c=true
is not present on the request
from vip.
Yeah I agree
from vip.
Resize is only called if it isn't already cached, but the cache key includes the pixel size requested. This will require reading the file into image
, get its bounds, and a lot of special casing. Setting Enlarge: true
will enlarge the width to the size requested and then the crop will happen as normal. Nothing else needs to change.
from vip.
This seems like a really easy change to me. I have time to do it, so no worries.
from vip.
@jrit for president
from vip.
I went to go open an issue like this and saw it already existed. Just seconding that it would be nice to be able to center-crop even when a size query parameter isn't specified. When I have a sec I'd like to open a PR so it's clearer in the documentation that at present, center-cropping will not work without a size parameter.
from vip.
@foresmac did I fix this on your now non-existent fork? Where did all the forks go?
from vip.
Ok, I see. This was technically meant to address a different issue that I think @jrit already fixed, but I agree that if c=true
and there is no s=xxx
param, that we can just give that option to vips and I think it would just work. (or at least it should.)
I also think that this probably could be solved by using https://github.com/h2non/bimg
from vip.
@jrit Possibly that is so. That particular branch only lives in my repo, and I still have it. I've been talking to @projectweekend to get a little time to address some (or all!) of the open issues by updating libvips
and move to a different Go binding for it, as well as updating to Go 1.5 to fix the issue with reading CMYK JPEGs.
from vip.
Let me know if you need anything, I'm 95% sure the crop handling is already in your media-proxy branch. I could maybe cherry pick out of my fork into master as well, if that won't get in your way.
from vip.
Oh, it looks like when @scottferg made vip public, it converted my fork into a private repo on my own account. Nuts. I'm sure there's a way to get it back up without losing anything, though.
from vip.
Just flip it public. That alternative libvips binding is the bees knees.
from vip.
I fixed it. I'm going to put in @jrit's fix for now and open a pull request to get it into mainline. I'll defer a better solution until I can use bimg
.
@rachelhyman Whoever is responsible for Systems on your project should be able to update the version running for your project, but if not let me know and I'll try to get it updated ASAP.
from vip.
Related Issues (20)
- video with elastic transcode on media-proxy HOT 8
- Vip mangles transparency HOT 3
- Add environment variables to the README
- gif resizing
- Become sentient
- Support CMYK JPEG files HOT 4
- Try grabbing image size without decoding the whole image HOT 1
- can't seem to upload an image to vip... probably user error HOT 14
- [suggestion] smart crop HOT 2
- Uploading images via HTTPS should return a secure URL for getting the image
- `broken pipe` error instead of 413 when using RetroFit
- Clean up docs
- Update drone.yml to push build to vokal DockerHub on successful merge HOT 1
- How can we tag specific release versions on DockerHub?
- Remove HTTP/2 support until Go 1.6 HOT 2
- Non-integer input for size requests causes full image to be returned HOT 2
- Allow trailing slash on upload endpoint
- Incorrect Content-Type header prevents image resizing HOT 3
- Configurable logging port HOT 1
- Dead project? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vip.