-
Notifications
You must be signed in to change notification settings - Fork 24
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
Load images directly from S3 bucket or using a resource #70
Comments
Hello @bensquire, No, you have to go via a string. This is oe of those features that's been talked about a lot, but has never quite happened, for various reasons. Maybe in the next version. Some background: |
@jcupitt Thanks for the prompt response and additional information. I'll hope it does make it into the next version as we're using php-vips to do image manipulation on GET requests, using resources I hope would improve speed/performance etc. Fingers crossed and thanks for the hard work! |
It probably wouln't make a huge difference since S3 will supply that 15mb in only a few ms. Speedup checklist:
|
Thanks @jcupitt I'm looking to use the thumbnail method as suggested. I can see how I can set width & height, but how can set whether I want it to crop or not? I noticed libvips has smart crop, but that wasn't accepted as an option? I don't think point 2 and 3 apply to us. But we have point 4 already. Thanks! |
Could you explain what kind of cropping you need to do? |
So for example, we have an image. It's 1024x768. We allow users to specify a new image size for thumbs with an optional "fit" flag. So if for example, I specify a new image size of 800x300, the difference between fit and non-fit, would be that one would equally trim the edges, the other would just force the content into the new image size... Actually as I play with the |
Ah OK. Just set
In PHP (untested): $thumb = Vips\Image::thumbnail($buffer, 800, ["height" => 300, "crop" => "centre"]); |
... that will crop the top and bottom equally. To force an aspect ratio change, use |
@jcupitt That is exactly what I was looking for, thank-you. How can I derive these sort of options for myself? |
You can use the
Or the C docs have the details: http://jcupitt.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail Obviously that's for C, but it and the PHP interface are just thin layers over the underlying object model, so it should be easy to see how to translate the options into PHP. It'd be nice if the PHP docs listed all the options, but sadly php-doc does not seem to allow optional arguments to magic methods. |
Thanks @jcupitt! |
PR to add true streaming, so you could (eg.) open an S3 bucket directly: |
Not sure if this is possible, but could php-vips load data directly from an S3 bucket? Currently we're having to load the image into a string and then pass that into php-vips. For example:
but this involves loading what could potentially be a 15MB file directly into memory before it can be processed.
Using:
results in an error:
even though we've registered our S3Connection within a stream wrapper. I also tried to load the image using a resource, e.g:
but get the error:
so that scuppered that idea as well.
Thanks in advance for the help!
The text was updated successfully, but these errors were encountered: