[suggestion] Add writeToB64 or writeToString
Hello
I would like to suggest a method to be available to writeToString or writeToB64 The method would convert to base64 the image or with dataUri on the fly instead of me base64_encode with another call.
Examples:
$buffer = $x->writeToB64(".jpg","uri") //would accept 'uri' or '' for pure base64 output;
//$buffer has this: 'data:image/jpeg;base64,....'
//automagically the mime type is already load
echo '<img src="'.$buffer.''">';
Currently base64_encode(....->writeToBuffer(".jpg")) works as well but I did not benchmarked it.
Hello @jarodium, that's a good idea.
libvips 8.9 lets you define custom input and output streams, so you could make one which wrote b64. It's not available from php-vips yet, unfortunately.
Let's tag this as an enhancement.
Hello @jcupitt
Are there news on this enhancement?
Since I don't find any example to make a custom input/output stream with php-vips, I will take this example and use Imagemagick to printout base64 with it
Best regards
Hi, I've almost finished a rewrite of php-vips to use the new FFI module. It should make it easy to support the target/source API. The code (in progress still) is here:
https://github.com/libvips/php-vips/tree/switch-to-php-ffi
Let's track streaming here: https://github.com/libvips/php-vips/issues/101