Comments (6)
Hello Christian, PNG is very slow, unfortunately, uncompressed TIFF would be a lot quicker.
Best of all would be simply passing a pointer to large array of uncompressed bytes (this is what pyvips does when interchanging images with numpy and PIL), but that would need additions to php-vips-ext.
Does imagick support creating an image from a memory array?
from php-vips-ext.
Imagick::exportImagePixels / Imagick::importImagePixels and #13 might be relevant here.
from php-vips-ext.
Oh dear Kleis, sorry, I'd forgotten about #13. Let's merge now since we're doing a new version. I'll have a look.
from php-vips-ext.
Ah, cool, great. No need to png/tiffsave anymore, will test soon
But regarding tiffsave, I have something I can't explain. Simple case:
$v = \Jcupitt\Vips\Image::newFromFile("animated.gif");
$v = $v->premultiply();
$v = $v->resize(0.5);
$v = $v->unpremultiply();
$v->pngsave("foo.png");
$v->tiffsave("foo.tiff");
The png looks like expected, but the tiff is totally wrong, looks like a black and white image (even without resize). Does it need something more?
Input:
Output (converted to a png outside of vips, since github doesn't support tiff):
from php-vips-ext.
Hello, premultiply / unpremultiply use float format, so you are saving as a float TIFF (12 bytes per pixel). Float TIFF usually uses 0 - 1 for black - white, rather than 0 - 255, so your 0 - 255 float TIFFs look white.
After unpremultiply, I would use cast()
to put image image back to the original band format, something like:
$original_format = $image->format;
$image = $image->premultiply()->resize(0.5)->unpremultiply();
$image = $image->cast($original_format);
Processing as float is obviously slower than byte or short, so I would only premultiply if necessary, and cast back as soon as possible after.
from php-vips-ext.
Thanks, that works. And with #13 in the works, I think we can close this issue again.
from php-vips-ext.
Related Issues (20)
- options for webpsave HOT 2
- vips_image_write_to_buffer doesn't support options param? HOT 5
- configure: error: you need at least libvips 8.2 for this module HOT 20
- php-vips has not been configured for PDF support HOT 19
- cannot find vips on pecl
- Alpinelinux 029 test fails HOT 5
- can't remove metadata on shared image HOT 3
- windows php extenstion HOT 3
- Recommended way of installing on PHP 7.4 HOT 6
- poor resize performance in php as compared to vipsthumbnail tool HOT 3
- Release 1.0.11 test fail on 32-bits HOT 5
- Preserving metadata HOT 6
- Issues with installation on php 7.2 on Ubuntu Bionic HOT 4
- segmentation fault with php7.4 on mac m1 HOT 5
- SIGABRT only on php-fpm - php8 on nginx - macOS Catalina and Big Sur HOT 34
- Segfaut in test suite HOT 9
- VipsOperation: class "bandand" not found HOT 2
- Opening pdf file HOT 5
- vips ext cause php fpm crash when curl_exec called on mac m1 HOT 3
- Calling `vips_call` Text with an `&` Errors 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 php-vips-ext.