Comments (11)
Hello, that's an interesting idea. It's certainly threaded, so it should work. The node.js libvips binding is async.
You'd need to write a little wrapper to do async dispatch I suppose, but I've never looked into it. You'd need to ask a PHP expert.
from php-vips-ext.
Working example using thread pool from libuv.
Required: PHP 7 ZTS, and php-uv module.
pecl install uv
http://pecl.php.net/package/uv
<?php
$loop = uv_default_loop();
$thread = function()
{
echo "THREAD-CALL\n";
$opt =
[
'height' => 1920,
'size' => 2,
'auto_rotate' => 1,
'crop' => 0,
'linear' => 0
];
$img = vips_call('thumbnail', null, '/opt/exif.jpg', 1920, $opt)['out']?? null;
if($img === null)
{
echo vips_error_buffer()."\n";
}
else
{
vips_image_write_to_file($img, '/var/www/thumbnail.jpg');
}
};
$after = function()
{
echo "THREAD-CALL-AFTER\n";
};
for($i = 0; $i < 4; $i++)
{
uv_queue_work($loop, $thread, $after);
}
uv_run($loop);
vips_call()
- Running in a separate thread, is overheads, async callback be rationally.
from php-vips-ext.
Woah, nice job!
from php-vips-ext.
PHP ZTS thread pool from libuv, often segmentation crash :(
We used GraphicsMagick, as worker, send to STDIN
http://www.graphicsmagick.org/batch.html
Run (spawn child process)
gm batch -
Write to STDIN
convert big.jpg -format "%w %h %[exif:DateTime]" -write info:- -strip -resize "250x250>" small.jpg\n
Read from STDOUT
800 600 2015-06-12\n
It is safely and works quickly, one worker process gm
, executing requests the pipeline mode from STDIN, in vips_tools
such prog there is? :)
Thank.
from php-vips-ext.
Yes, vips has vipsthumbnail
, a command-line resizer. It's file operations only though, so you'd need to go via the filesystem.
We should be able to get the libuv one working though, I wonder what the issue is. I'll see if I can reproduce it here.
from php-vips-ext.
I looked at vips lua, I can write lua script, use as child PHP process
$work = Worker::spawn('luajit my_script.lua');
$work->write('...'); // write to STDIN script.lua
from php-vips-ext.
I'm working on vips-lua at the moment, it's not finished yet. Another week or two.
You could write a php script and call that as a child process, that would be a simple solution.
libvips is used with libuv in node.js with very large deployments (tumblr, etc.) and it works fine, so I think the crashes you are seeing must just be problems with php-vips-ext. I suppose we must add some locks to this file:
https://github.com/jcupitt/php-vips-ext/blob/master/vips.c
Do you know what the rules are for what calls need locks? Is there a document I can read?
from php-vips-ext.
Do you know lua well? If you do, some help on lua-vips would be very welcome. I'm not a lua expert at all, and it would be wonderful if someone who knew what they were doing could check it for dumbness.
from php-vips-ext.
Do you know what the rules are for what calls need locks? Is there a document I can read?
I'm not an expert in multithreading, my experiments showed that PHP ZTS and libuv without Vips, segmentation errors, so I abandoned this idea.
Crashing main PHP process is not allowed, our main PHP process is engaged in important business logic.
Do you know lua well? If you do, some help on lua-vips would be very welcome. I'm not a lua expert at all, and it would be wonderful if someone who knew what they were doing could check it for dumbness.
I wrote my first script on lua yesterday, i learning :)
from php-vips-ext.
I resolve the cause, this problem in php-ext-raphf
is thread not safe, without it everything works well.
from php-vips-ext.
Good news! I'll close.
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.