0

How i can limited number of active threads in vips lib from php code? I want to cut big image for tiles but have kill script from hoster for limit of proc i guess.

In web i cant fined good examples for use vips like a php module. I make this code and this is works, but do not have a limits.

$im = vips_image_new_from_file('./big_image.png', ['access' => 'sequential'])["out"];
vips_call('dzsave', $im, './folder', ["overlap" => 0, "tile-size" => 256, "depth" => "one"]);
FridayJew
  • 11
  • 5

1 Answers1

1

I found function for this:

vips_concurrency_set($number_of_threads);

After use 1 or 2 on it (maybe i can use more, i don't try) hosting provider don't kill process but lib work very fast whatever.

FridayJew
  • 11
  • 5
  • I would use php-vips instead -- it's a nicer interface, and properly documented. You can also set the environment variable `VIPS_CONCURRENCY`, if that's easier. https://github.com/libvips/php-vips – jcupitt Sep 12 '20 at 16:37
  • im don't use composer, this is work on shared hosting. – FridayJew Sep 12 '20 at 19:35
  • You don't need to use composer if you don't want to -- just copy the php-vips source into your project (that's all composer does). – jcupitt Sep 13 '20 at 13:03
  • for what composer needed if can do not use them and get same result ? – FridayJew Sep 13 '20 at 20:46
  • Composer will manage a set of dependencies for you and keep them up to date automatically -- but you can just copy the files yourself if you like. You can use composer on a shared host. – jcupitt Sep 14 '20 at 13:59