php-vips
php-vips copied to clipboard
[question] How to use True Streaming in PHP?
Hello @jcupitt hope to find you well.
Could you please guide me how to use True Streaming in PHP?
I read the release notes, but could not figure how to do in PHP, tried looking in the source code but did not go to far.
My use case is a thumbnailing service on S3, source and target images stay on S3.
I already have it working, but do the old way:
- first I get the S3 object with AWS SDK PHP
- then use newFromBuffer
- then do the operations with thumbnail_image
- then $image->writeToFile (I am storing on disk for now, but the goal is to store on S3)
Could you please share some insights?
Have a good day.
Hello, the new streaming stuff hasn’t been added to the PHP binding yet. It’s not hard, just that no ones got around to it.
PRs very welcome, of course.
Thanks, I understand!
Let's reopen as a reminder to fix this.
I'm willing to help on this as I really need this feature, but I have zero idea where to start.
Hello, you need to add the relevant chunks of the libvips API to php-vips-ext, then expose that in a nice way in php-vips.
The ruby version should give a hint as to the libvips API you need to support and the sort of API you could expose in php-vips, though of course you'd need to implement in C and php:
https://github.com/libvips/ruby-vips/blob/master/lib/vips/source.rb https://github.com/libvips/ruby-vips/blob/master/lib/vips/target.rb https://github.com/libvips/ruby-vips/blob/master/lib/vips/image.rb#L425
An alternative would be to get rid of php-vips-ext and redo everything in php-ffi, which might now have enough features to support php-vips.
https://www.php.net/manual/en/book.ffi.php
I think it used to be missing some stuff, I forget exactly what. Getting rid of php-vips-ext would make php-vips much simpler to install and maintain, so there would be other benefits.
I might give it a go to using FFI.
I understand that I need to map the C headers to functions to do that, and provide the path to the library for my architecture right? Sorry, but my experience in FFI is very limited.
That's right. You can use the ruby one as a guide, or there's python too:
https://github.com/libvips/pyvips
They both use ffi to wrap libvips.
There are some general notes in the "binding" chapter of the docs:
https://libvips.github.io/libvips/API/current/binding.md.html
Thank you for all the useful links. Before I send a PR, I would like to play with it and see if I can do it well. I'll create a repo for trying to implement a small subset of the api. Would you be willing to review it and give me some feedback?
Of course, I'd be delighted.
I'm just leaving this here for myself. It has some info I would like to come back to.
https://github.com/libvips/libvips/issues/1885
We have a PR for this feature, so let's close this issue and move discussion there.