Coder Social home page Coder Social logo

Comments (21)

jrit avatar jrit commented on September 16, 2024

sorry about that, this is in fact an issue

from vip.

scottferg avatar scottferg commented on September 16, 2024

Make up your damn mind

from vip.

foresmac avatar foresmac commented on September 16, 2024

@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.

jrit avatar jrit commented on September 16, 2024

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.

foresmac avatar foresmac commented on September 16, 2024

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.

foresmac avatar foresmac commented on September 16, 2024

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.

scottferg avatar scottferg commented on September 16, 2024

I'm not seeing how Enlarge: true solves anything to be honest

from vip.

jrit avatar jrit commented on September 16, 2024

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.

jrit avatar jrit commented on September 16, 2024

by "no center-crop" I mean c=true is not present on the request

from vip.

scottferg avatar scottferg commented on September 16, 2024

Yeah I agree

from vip.

foresmac avatar foresmac commented on September 16, 2024

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.

jrit avatar jrit commented on September 16, 2024

This seems like a really easy change to me. I have time to do it, so no worries.

from vip.

scottferg avatar scottferg commented on September 16, 2024

@jrit for president

from vip.

rachelhyman avatar rachelhyman commented on September 16, 2024

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.

@foresmac @scottferg @jrit

from vip.

jrit avatar jrit commented on September 16, 2024

@foresmac did I fix this on your now non-existent fork? Where did all the forks go?

from vip.

foresmac avatar foresmac commented on September 16, 2024

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.

foresmac avatar foresmac commented on September 16, 2024

@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.

jrit avatar jrit commented on September 16, 2024

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.

foresmac avatar foresmac commented on September 16, 2024

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.

scottferg avatar scottferg commented on September 16, 2024

Just flip it public. That alternative libvips binding is the bees knees.

from vip.

foresmac avatar foresmac commented on September 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.