GithubHelp home page GithubHelp logo

php-vips-ext's Introduction

Low-level PHP binding for libvips

This extension is deprecated php-vips 2.0+ has switched to FFI for calls into the libvips binary, so this extension is no longer necessary. It will not be updated again (though it might still be useful if for some reason you don't / can't update to php-vips 2.0).

This extension lets you use the libvips image processing library from PHP 7 and PHP 8.

This is not supposed to be used directly! Install this, then use php-vips 1.x to layer a nice (and documented!) API on top of this extension.

libvips is fast and needs little memory. The vips-php-bench repository tests php-vips against imagick and gd: on that test, and on my laptop, php-vips is around four times faster than imagick and needs 10 times less memory.

Example

#!/usr/bin/env php
<?php

# never use this extension directly! this is just an example
$x = vips_image_new_from_file($argv[1])["out"];
$x = vips_call("invert", $x)["out"];
vips_image_write_to_file($x, $argv[2]);

Almost all operations return an array of result values. Usually there is a single result called "out".

Use vips_call() to call any operation in the vips library. There are around around 300 operations available, see the vips docs for an introduction:

http://libvips.github.io/libvips/API/current/

Arguments can be long, double, image, array of long, array of double or array of image. The final argument to vips_call() is an array of operation options.

php-vips layers a nice API, including full docs, on top of this extension, see:

https://github.com/libvips/php-vips

Installing

First install the libvips library. It will be in your package manager on linux, it's in brew and MacPorts on macOS, or the vips website has Windows binaries.

Next, install this extension:

$ pecl install vips

And add:

extension=vips.so

to your php.ini.

Finally, add vips to your composer.json to pull in the high-level PHP API.

    "require": {
            "jcupitt/vips" : "1.0.0"
    }

The high-level API has all the documentation, see:

https://github.com/libvips/php-vips

Development: preparation

PHP is normally built for speed and is missing a lot of debugging support you need for extension development. For testing and dev, build your own php. I used 7.0.11 and configured with:

$ ./configure --prefix=/home/john/vips --enable-debug --enable-maintainer-zts \
    --enable-cgi --enable-cli --with-readline --with-openssl --with-zlib \
    --with-gd --with-jpeg-dir=/usr --with-libxml-dir=/usr --enable-mbstring 

You'll need libvips 8.2 or later, including all the headers for development. On linux, install with your package manager. On macOS, install with brew or MacPorts. For Windows, download a zip from the libvips website, or build your own.

Development: regenerate build system

$ pear package

To make vips-1.0.13.tgz.

To install by hand:

$ phpize

To scan config.m4 and your php install and regenerate the build system.

Development: configure

Run

$ ./configure 

Check the output carefully for errors, and obviously check that it found your libvips.

Development: make, test and install

Run:

$ make

To build the module to the modules/ directory in this repository.

Don't post php-vips test results to php.net! Stop this with:

$ export NO_INTERACTION=1

Test with:

$ make test

Finally, install to your php extensions area with:

$ make install

Add extension=vips.so to php.ini, perhaps in ~/vips/lib/php.ini, if you configured php as above.

Development: regenerate vips_arginfo.h

Run:

$ curl -LO https://github.com/php/php-src/raw/ffacda14b88be797a466f472359f306d626e698f/build/gen_stub.php
$ php gen_stub.php

Links

http://php.net/manual/en/internals2.php

https://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/

https://devzone.zend.com/317/extension-writing-part-ii-parameters-arrays-and-zvals/

https://devzone.zend.com/446/extension-writing-part-iii-resources/

php-vips-ext's People

Contributors

chregu avatar jcupitt avatar jmikola avatar kleisauke avatar remicollet avatar tbk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-vips-ext's Issues

vips ext cause php fpm crash when curl_exec called on mac m1

php 7.4.28
tried with vips 8.12.2 from homebrew
tried with compile vips from source (master branch 8.13.0) and re-compile php-vips-ext to make sure headers and library version matched with 8.13.0
and tried with OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

still not working. get 502 error from nginx

get this error from php-fpm only: child 90407 exited on signal 11 (SIGSEGV) after 390.827437 seconds from start

related to #42

Release 1.0.11 test fail on 32-bits

Just used to upgrade to 1.0.11 and test tests/042.phpt started to fail 32-bits on x86 and armv7

vips-1.0.11/tests$ cat 042.diff 
001- pass set_metadata
002+ 
003- pass get_metadata
003+ Notice: Trying to access array offset on value of type int in /mnt/community/php7-pecl-vips/src/vips-1.0.11/tests/042.php on line 21

It means that it fails somehow according to https://github.com/libvips/php-vips-ext/blob/master/vips.c#L1636

PS: here's CI runs

Issues with installation on php 7.2 on Ubuntu Bionic

Hello @jcupitt

I was trying the code from #39 but I keep getting this error:

Fatal error: Uncaught Error: Call to undefined function Jcupitt\Vips\vips_type_from_name() in 
/var/www/html/backoffice/vendor/jcupitt/vips/src/Utils.php:95 Stack trace: #0 

/var/www/html/imagem.php(169): 

Jcupitt\Vips\Utils::typeFromName('VipsBlob') #1 

I would like to install/upgrade the extension via pecl, but pecl bugs me with that I need vips 8.2 for that.

I have already updated vips, following the gist here. This is not the latest version of vips.

Linux box: Ubuntu Bionic ( 18:04 )

My PHP info has this information:

PHP Version: 7.2
Vips headers version | 8.4.5
Vips library version | 8.4.5
Vips ABI version | -1.-1.-1
Major version | 8
Minor version | 4
Micro version | 5

vips --version issues this:

vips-8.11.0-Tue Apr 13 10:44:43 UTC 2021

composer complains with this ( composer.json entry has ^1.0 has the version required )

Problem 1
    - jcupitt/vips[v1.0.0, ..., v1.0.8] require ext-vips >=0.1.2 -> it is missing from your system. Install or enable PHP's vips extension.
    - Root composer.json requires jcupitt/vips ^1.0 -> satisfiable by jcupitt/vips[v1.0.0, ..., v1.0.8].
This is plenty of evidence that PHP no longer has php-vips-ext installed and enabled.

I am intending in following the last comment from @joppuyo ( see issue #36 ) but I would like to make sure if :

  1. It works with the version I installed from the gist above.
  2. I can install it without libvips-dev ( I fear that installing from the repos may present compat issues, no? )

I have also tried to setup libvips as stated in the docs but to no avail. I could try again, but now following instructions on the github page instead of the website.

On a final note I do wish the distro's repo maintainers add an updated vips to their repos... It's a pain in the neck watching the wonderful things we can do with vips ( and fast ) and not being able to properly update the software...

Best regards and thank you for your patience xD

vips_image_write_to_buffer doesn't support options param?

Really weird as I can't see any big difference between vips_image_write_to_buffer and vips_image_new_from_file. Basically I'm trying this:

<?php

$image = vips_image_new_from_file('/home/nicsev/dev/images/t3pos7b.jpg', ['access' => 'sequential'])['out'];
vips_image_write_to_file($image, 'out.jpg', ['optimize_coding' => true, 'strip' => true, 'Q' => 10]);

$buf = vips_image_write_to_buffer($image, '.jpg', ['optimize_coding' => true, 'strip' => true, 'Q' => 10]);
var_dump($buf);

vips_image_write_to_file works fine. At least with .jpg, it doesn't do anything to .png but at least it doesn't crash.

vips_image_write_to_buffer on the other hand returns -1 on both png and jpg, so long as you give it parameters, though it does work if you don't give it any parameters, or if you give it strings only parameters (but then it seems to ignore them).

Am I an idiot? Also, where can I find the documentation/list over options I can give vips_image_write_to_* functions?

Preserving metadata

Hello

I facing a strange issue with VIPS. Here's what i'm doing:

  1. Pickup any image ( between JPG and PNG ).
  2. Copy it to the /tmp/ folder with tempnam().
  3. Add XMP metadata to the temp image using Imagick ( using the profiles functions (setImageProfile/getImageProfile("xmp")) and DomDocument.
  4. Saving the image to the final destination with VIPS.

I use the following when saving the image with VIPS ( see bellow )

  $image =  \Jcupitt\Vips\Image::newFromFile('/tmp/image',['access' => 'sequential']);
  $image->writeToFile($destination.".webp");

I figure that I need to save webp while keeping profile information from the original file ( somehow online exif viewers complain the image doesn't have any ). I have found out that vips has functions to set profile ( "vips_profile_set, function in gate", but the docs show there is no link for it at this time.

Does anyone know a way I can maintain the XMP metadata or write it again into the destination file using only vips? Some servers may not have Imagick with Webp support and I don't want to risk it by opening the file and add XMP again (with Imagemagick), plus I save that extra step.

Thank you in advance.
Best regards

Install problem

Error:
PHP Warning: PHP Startup: Unable to load dynamic library 'vips.so' (tried: /usr/local/Cellar/php/7.2.2_14/lib/php/20170718/vips.so (dlopen(/usr/local/Cellar/php/7.2.2_14/lib/php/20170718/vips.so, 9): image not found), /usr/local/Cellar/php/7.2.2_14/lib/php/20170718/vips.so.so (dlopen(/usr/local/Cellar/php/7.2.2_14/lib/php/20170718/vips.so.so, 9): image not found)) in Unknown on line 0

MacOs, php 7.2, install from pecl

add support for vips_interpolate_new()

We're testing this extension in our production environment with a small number of requests (A/B-testing). Unfortunately, this error occurs random (around 5% requests passed through php-vips-ext) in our log:

WARNING: [pool www] child 19695 said into stderr: "(banana:19695): GLib-GObject-CRITICAL **: g_value_set_object: assertion 'g_value_type_compatible (G_OBJECT_TYPE (v_object), G_VALUE_TYPE (value))' failed"

We could not figure out where this error comes from and for which image. It looks like the image is successfully returned.

configure: error: you need at least libvips 8.2 for this module

Hi, I'm trying to install this ext on MacOs

brew install vips
pecl install vips

But have following error:
configure: error: you need at least libvips 8.2 for this module

vips -v reports: vips-8.8.0-Sat May 11 11:55:18 UTC 2019

MacOs: 10.14.5 (18F132)
PHP 7.3.6
Homebrew 2.1.6

Probably I'm missing something?

Suppress VIPS-WARNING output?

When I try to get certain images (can reproduce it with CMYK images) as tiff, I get a

(banana:11322): VIPS-WARNING **: rounding up IPCT data length

on the console. The warning itself is fine in this case, we don't care much about IPCT data at that point. But the output of the Warning is kinda ugly and distracting. Is there any way to suppress it? The PHP way with the @ in front doesn't work.

Phpinfo says no lcms

I've built libvips with lcms2 and vipsthumbnail works fine on the command line but my phpinfo says "ICC profile support with lcms: no" and I get an error about icc_import not found when trying to thumbnail a cmyk image. Any idea why the vips extension isn't detecting lcms? Do I need to pass any parameters to pecl when installing?

VipsOperation: class "bandand" not found

Hello,
trying to get "bandand" running with php-vips-ext but it's always failing with "VipsOperation: class "bandand" not found".
Any ideas on that?
thx, bye from Austria
Andreas S.

ps) trying to swap all transparent Pixel in an Image with a defined color like mentioned there: libvips/libvips#872 - but struggling with above Error.

SIGABRT only on php-fpm - php8 on nginx - macOS Catalina and Big Sur

I'm only having this issue on macOS Catalina and Big Sur. Linux works as expected.

✅ Vips cli works as expected (vips-8.11.0 from homebrew).
✅ Calling php-vips-ext functions like vips_call() from php cli works as expected.

❌ Loading a local browser page (homebrew nginx with php-fpm) that calls vips_call() returns 502 Bad Gateway and logs:
WARNING: [pool www] child ... exited on signal 6 (SIGABRT) ...
(running the same php from php cli works as expected)

Also I've found that if vips.so is enabled, any php code that calls openssl (Google cloud apis, stripe api, etc) causes the same 502 Bad Gateway error, even if there are no calls to php-vips-ext functions, but ONLY on php-fpm and ONLY when vips.so is enabled.
If I run the same php code from php CLI, everything works as expected.
If I disable vips.so, all the normal calls to openssl work fine.

I've tried latest php 8.0.7 from homebrew and also php 8.0.6 and 8.0.7 from phpbrew.
I've tried installing php-vips-ext from pecl and also from phpbrew and pickle, also versions 1.0.12 and 1.0.11.
I've tried running php-fpm and nginx as sudo (for permission errors), it didn't work but maybe I messed up something.

Everything worked as expected until last weekend or so, I don't know what changed or what update caused this to start failing.
I've since updated from Catalina to Big Sur thinking it might fix it but... no. 😵

I'd love to fix this or help fix this, but I don't know what my next steps should be.

By the way, thank you very much for vips and php-vips-ext.

The fastest way to convert from vips to imagick?

Question: Anyone knows what could be the fastest way from a vips resource to an imagick resource (retaining the image, of course) and maybe vice versa. I sometimes need to convert (for example for saving gif) from one to the other.
I basically currently do:

$image = new \Imagick();
$imagick->readImageBlob($vips->pngsave_buffer(['interlace' => false]));

Any better recommended way?

Async vips_call()

Hi.
Can vips_call work asynchronously?

<?php

vips_call($cmd, $args, function($result){
// callback completion
}) 

Thank.

P.S.
We use PHP cli script daemon mode, libuv as EventLoop.

can't remove metadata on shared image

I tested my project with libvips 8.9 and get lots of
can't remove metadata "orientation" on shared image
warnings. This seems to be expeced according to libvips/libvips#1483 and lovell/sharp#1986

Is this something, which can be improved in the extension or do I have to copy images before applying metadata changes in my application code?

Release 1.0.5 on PECL

Now that libvips 8.5.2 is released (and to try out the image type sniffers in production), it would be nice to have a release for the PHP vips extension (1.0.5) on PECL.

Alpinelinux 029 test fails

Trying to upgrade to latest version I faced with failed test alpinelinux/aports#11938

used to add debug information

--- 029.phpt.1	2019-11-26 18:06:12.979624226 +0200
+++ 029.phpt	2019-11-26 18:09:12.768886144 +0200
@@ -13,6 +13,7 @@
   $err = vips_call("add", $image, $rg);
   $msg = vips_error_buffer();
 
+var_dump($msg);
   if ($err == -1 &&
     $msg == "add: not one band or 3 bands\n") {
     echo "pass";

Not I see there's more then one message

$ cat 029.log 

---- EXPECTED OUTPUT
pass
---- ACTUAL OUTPUT
string(106) "vips_realpath: unable to form filename
unix error: No such file or directory
add: not one band or 3 bands
"
---- FAILED

Cant fine where vips_realpath defined to catch error

new_from_memory / write_to_memory

It would be nice to wrap an image around a memory array or to write an image to a large memory array. This can be useful for moving images between libvips and imagemagick or to calculate the perceptual hash of an image (see below).

The new functions can be named like this:
Extension: new_from_memory, write_to_memory.
php-vips: Image::newFromMemory, ->writeToMemory.

I can open a PR at the php layer to support these new functions if this has been implemented in the extension.

If you are wondering why I need this:
For our test cases we are calculating the perceptual hash of an image (based on the dHash algorithm) to verify the similarity of expected vs actual images (using a distance threshold). It looks like this (so ->copyMemory and ->getpoint are the important ones). If there's a ->writeToMemory function it could be somewhat optimized.

windows support

The config.w32 we have at the moment is just a quick copy-paste and hasn't been tested.

We need to find a Windows expert to fix it up and test it.

php-vips has not been configured for PDF support

I've encountered an error while using php-vips and I'm encountering this error vips_image_get: field "n-pages".

I've followed all the instructions on the installation of this extension except for the composer. I installed the library using the command found on the composer composer require jcupitt/vips instead of adding "jcupitt/vips" : "1.0.0" on my composer.json. I'm not sure if this is the problem. Thanks!

Segfaut in test suite

Probably since recent changes in libvips

Using PHP 7.4, 8.0 with libvips 8.11.3

TEST 12/33 [tests/012.phpt]
========DIFF========
002+ Termsig=11
========DONE========
FAIL new_from_buffer works [tests/012.phpt] 

TEST 33/33 [tests/042.phpt]
========DIFF========
004+ 
005+ Termsig=11
========DONE========
FAIL can set metadata [tests/042.phpt] 
========================================

Get EXIF value by field name

<?php

$img = vips_image_new_from_file('/opt/exif.jpg')['out']?? null;

$data = vips_image_get($img, 'exif-Model'); // return -1
$data = vips_image_get($img, 'exif-data'); // return ['out' => "all fields as raw string 50 Kb"]

How to get EXIF value by field name?
Thank.

Expose Vips library version to PHP

It would be useful to know which vips library version is used, so that the user can be warned, in case it's not the correct one with features missing. I see that there's the vips_version() function in vips, but I couldn't figure out, how to access that from PHP.

Something like

PHP_FUNCTION(vips_version) {
  char digits[256];
  vips_snprintf(digits, 256, "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
  RETVAL_STRING(strdup(digits))
}

would maybe do it already (my PHP C know how is too rusty, but I can give it a try, if it's not already accessible through other means)

poor resize performance in php as compared to vipsthumbnail tool

Hi John,

vips-8.9.2-Tue Apr 21 09:26:11 UTC 2020
PHP 7.4.6 (cli) (built: May 14 2020 10:03:28) ( NTS )
php-vips-ext 1.0.10
Debian buster
Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz

test image

19M in size

jpg.jpg: 8644x8444 uchar, 3 bands, srgb, jpegload
width: 8644
height: 8444
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 11.811
yres: 11.811
filename: jpg.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:2:0
<?php

$image = vips_image_new_from_file('jpg.jpg')['out'];

$args = ['height' => 521, 'size' => 'force', 'no-rotate' => true];

$result = vips_call("thumbnail_image", $image, 8572, $args)['out'];
vips_image_write_to_file($result, __DIR__. '/1.jpg');

time php bechmark.php jpg in php cli mode


php-vips-ext init
enabling vips leak testing ...
vips_image_new_from_file:
vips_image_new_from_file: name = jpg.jpg
vips_php_call_array:
vips_php_call_new: VipsForeignLoadJpegFile
    option_string = "", argc = 1
vips_php_call_array: analyzing input args ...
vips_php_call_array: setting args from option_string ...
vips_php_call_array: setting required input args ...
    VipsForeignLoadJpegFile.filename = "jpg.jpg"
vips_php_call_array: testing argc ...
vips_php_call_array: setting optional input args ...
vips_php_call_array: building ...
vips_php_call_array: getting required output ...
    VipsForeignLoadJpegFile.out = ((VipsImage*) 0x563454aa1020)
vips_php_call_array: getting optional output ...
vips_php_call_free:
vips_php_call_array: success!
vips_call:
vips_php_call_array:
vips_php_call_new: thumbnail_image
    option_string = "", argc = 2
vips_php_call_array: analyzing input args ...
vips_php_call_array: setting args from option_string ...
vips_php_call_array: setting required input args ...
    thumbnail_image.in = ((VipsImage*) 0x563454aa1020)
    thumbnail_image.width = 8572
vips_php_call_array: testing argc ...
vips_php_call_array: setting optional input args ...
vips_php_set_optional_input:
    thumbnail_image.height = 521
    thumbnail_image.size = ((VipsSize) VIPS_SIZE_FORCE)
    thumbnail_image.no-rotate = TRUE
vips_php_call_array: building ...
vips_php_call_array: getting required output ...
    thumbnail_image.out = ((VipsImage*) 0x563454ab7650)
vips_php_call_array: getting optional output ...
vips_php_get_optional_output:
vips_php_call_free:
vips_php_call_array: success!
vips_image_write_to_file:
	0x563454ab7650 -> /var/www/samples-api/tests/1.jpg
vips_php_call_array:
vips_php_call_new: VipsForeignSaveJpegFile
    option_string = "", argc = 1
vips_php_call_array: analyzing input args ...
vips_php_call_array: setting args from option_string ...
vips_php_call_array: setting required input args ...
    VipsForeignSaveJpegFile.in = ((VipsImage*) 0x563454ab7650)
    VipsForeignSaveJpegFile.filename = "php.jpg"
vips_php_call_array: testing argc ...
vips_php_call_array: setting optional input args ...
vips_php_call_array: building ...
vips_php_call_array: getting required output ...
vips_php_call_array: getting optional output ...
vips_php_call_free:
vips_php_call_array: success!
php_free_gobject: 0x563454ab7650
php_free_gobject: 0x563454aa1020
php-vips-ext shutdown
memory: high-water mark 59.73 MB

real	0m17.968s
user	0m14.443s
sys	0m21.947s

time vipsthumbnail --vips-leak --vips-progress jpg.jpg -s 8572x521!

vipsthumbnail temp-23: 8572 x 521 pixels, 8 threads, 128 x 128 tiles, 256 lines in buffer
vipsthumbnail temp-23: done in 0.465s          
memory: high-water mark 94.07 MB

real	0m0.515s
user	0m0.551s
sys	0m0.057s
679K php.jpg
679K tn_jpg.jpg
php.jpg: 8572x521 uchar, 3 bands, srgb, jpegload
php.jpg: width: 8572
php.jpg: height: 521
php.jpg: bands: 3
php.jpg: format: uchar
php.jpg: coding: none
php.jpg: interpretation: srgb
php.jpg: xoffset: 0
php.jpg: yoffset: 0
php.jpg: xres: 11.811
php.jpg: yres: 11.811
php.jpg: filename: php.jpg
php.jpg: vips-loader: jpegload
php.jpg: jpeg-multiscan: 0
php.jpg: jpeg-chroma-subsample: 4:2:0
php.jpg: exif-data: 186 bytes of binary data
php.jpg: resolution-unit: in
php.jpg: exif-ifd0-Orientation: 1 (Top-left, Short, 1 components, 2 bytes)
php.jpg: exif-ifd0-XResolution: 300000/1000 (300.000, Rational, 1 components, 8 bytes)
php.jpg: exif-ifd0-YResolution: 300000/1000 (300.000, Rational, 1 components, 8 bytes)
php.jpg: exif-ifd0-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
php.jpg: exif-ifd0-YCbCrPositioning: 1 (Centered, Short, 1 components, 2 bytes)
php.jpg: exif-ifd2-ExifVersion: Exif Version 2.1 (Exif Version 2.1, Undefined, 4 components, 4 bytes)
php.jpg: exif-ifd2-ComponentsConfiguration: Y Cb Cr - (Y Cb Cr -, Undefined, 4 components, 4 bytes)
php.jpg: exif-ifd2-FlashPixVersion: FlashPix Version 1.0 (FlashPix Version 1.0, Undefined, 4 components, 4 bytes)
php.jpg: exif-ifd2-ColorSpace: 65535 (Internal error (unknown value 65535), Short, 1 components, 2 bytes)
php.jpg: exif-ifd2-PixelXDimension: 8572 (8572, Long, 1 components, 4 bytes)
php.jpg: exif-ifd2-PixelYDimension: 521 (521, Long, 1 components, 4 bytes)
php.jpg: orientation: 1


tn_jpg.jpg: 8572x521 uchar, 3 bands, srgb, jpegload
tn_jpg.jpg: width: 8572
tn_jpg.jpg: height: 521
tn_jpg.jpg: bands: 3
tn_jpg.jpg: format: uchar
tn_jpg.jpg: coding: none
tn_jpg.jpg: interpretation: srgb
tn_jpg.jpg: xoffset: 0
tn_jpg.jpg: yoffset: 0
tn_jpg.jpg: xres: 11.811
tn_jpg.jpg: yres: 11.811
tn_jpg.jpg: filename: tn_jpg.jpg
tn_jpg.jpg: vips-loader: jpegload
tn_jpg.jpg: jpeg-multiscan: 0
tn_jpg.jpg: jpeg-chroma-subsample: 4:2:0
tn_jpg.jpg: exif-data: 186 bytes of binary data
tn_jpg.jpg: resolution-unit: in
tn_jpg.jpg: exif-ifd0-Orientation: 1 (Top-left, Short, 1 components, 2 bytes)
tn_jpg.jpg: exif-ifd0-XResolution: 300000/1000 (300.000, Rational, 1 components, 8 bytes)
tn_jpg.jpg: exif-ifd0-YResolution: 300000/1000 (300.000, Rational, 1 components, 8 bytes)
tn_jpg.jpg: exif-ifd0-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
tn_jpg.jpg: exif-ifd0-YCbCrPositioning: 1 (Centered, Short, 1 components, 2 bytes)
tn_jpg.jpg: exif-ifd2-ExifVersion: Exif Version 2.1 (Exif Version 2.1, Undefined, 4 components, 4 bytes)
tn_jpg.jpg: exif-ifd2-ComponentsConfiguration: Y Cb Cr - (Y Cb Cr -, Undefined, 4 components, 4 bytes)
tn_jpg.jpg: exif-ifd2-FlashPixVersion: FlashPix Version 1.0 (FlashPix Version 1.0, Undefined, 4 components, 4 bytes)
tn_jpg.jpg: exif-ifd2-ColorSpace: 65535 (Internal error (unknown value 65535), Short, 1 components, 2 bytes)
tn_jpg.jpg: exif-ifd2-PixelXDimension: 8572 (8572, Long, 1 components, 4 bytes)
tn_jpg.jpg: exif-ifd2-PixelYDimension: 521 (521, Long, 1 components, 4 bytes)
tn_jpg.jpg: orientation: 1

please let me know if you need more info.

Does not install on Alpine Linux

Using Alpine (edge/testing) in Docker. After running pecl install vips I get the following output:

...
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserBdcDKn/vips-1.0.7/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1  -I. -I/tmp/pear/temp/vips -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserBdcDKn/vips-1.0.7/include -I/tmp/pear/temp/pear-build-defaultuserBdcDKn/vips-1.0.7/main -I/tmp/pear/temp/vips -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/vips/vips.c -o vips.lo
mkdir .libs
 cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/tmp/pear/temp/vips -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserBdcDKn/vips-1.0.7/include -I/tmp/pear/temp/pear-build-defaultuserBdcDKn/vips-1.0.7/main -I/tmp/pear/temp/vips -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/vips/vips.c  -fPIC -DPIC -o .libs/vips.o
In file included from /tmp/pear/temp/vips/vips.c:19:0:
/usr/include/vips/vips.h:85:18: fatal error: glib.h: No such file or directory
 #include <glib.h>
                  ^
compilation terminated.
make: *** [Makefile:194: vips.lo] Error 1
ERROR: `make' failed

Vips version used: 8.5.6
I'm using the following Dockerfile:

FROM    alpine:edge
RUN     apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing \
        vips-tools vips-dev glib-dev php7-dev php7-pear build-base libxml2-dev
RUN     pecl install vips

Although installing from source (version 8.4.5) as described here works fine.

cannot find vips on pecl

Hi,

i'm trying to install visp package from pecl on my ubuntu server but when i do
pecl install vips

i've that output :

No releases available for package "pecl.php.net/vips"
install failed

How can i install it?

Error when opening two files with same filename

I have strange error, not sure it it's caused by extension or libvips, and if you will be able to reproduce it.
First - the code i'm using for narrowing the problem:

$originalFile = $path."gun.jpg";
		$resultFile = $uploadPath."result-clean.jpg";

		$image = \Jcupitt\Vips\Image::newFromFile($originalFile);
		$image->writeToFile($resultFile);

		header("Content-Type: image/jpg");
		echo file_get_contents($resultFile);

steps to reproduce:

  1. create file gun.jpg in $path
  2. run once this script
  3. result-clean.jpg will be created
  4. modify gun.jpg ( for example add some line in paint ).
  5. remove result-clean.jpg
  6. re-run this script - result-clean.jpg will be created, however copied from gun.jpg BEFORE modification

when you will change source filename, and re run, modified version will be used.

It looks like there is some kind of cache storing loaded files (?).
I'm using nginx and php-fpm. Restarting fpm "clears" this "cache" ( so new file is used ).

Any ideas ?

segmentation fault with php7.4 on mac m1

hey there,
i have found the vips.so extension throwing a segmentation fault on my macbook m1 (arm chip).

./vendor/bin/phpunit
PHPUnit 9.5.5 by Sebastian Bergmann and contributors.

.......................                                           23 / 23 (100%)

Time: 00:00.648, Memory: 60.50 MB

OK (23 tests, 119 assertions)
[1]    64109 segmentation fault  ./vendor/bin/phpunit

disabling the extension removes the segfault at the end of phpunit

php:

PHP 7.4.20 (cli) (built: Jun  3 2021 19:10:14) ( NTS )

vips:


vips property => value
Vips headers version => 8.11.0
Vips library version => 8.11.0
Vips ABI version => 55.0.13
Major version => 8
Minor version => 11
Micro version => 0
Cache max mem => 104857600
Cache max operations => 100
Cache current operations => 0
Cache max open files => 100
Memory allocations => 0
Memory currently allocated => 0
Memory high water => 0
Concurrency => 8
SIMD support with liborc => yes
JPEG support => yes
PNG support => yes
TIFF support => yes
GIF support => yes
OpenEXR support => yes
load OpenSlide => yes
load Matlab => yes
load PDF => yes
load SVG => yes
FITS support => yes
WebP support => yes
HEIF support => yes
load with libMagick => yes
Text rendering support => yes
ICC profile support with lcms => yey
vips -v
vips-8.11.0-Wed Jun  9 18:20:35 UTC 202

thank you for this awesome image library!

options for webpsave

Many of the webp options of webpsave are rejected.
I would have assumed that the options for libvips vips_webpsave would be working

The following works:

vips_call('webpsave', $im, ['Q' => 80]);

But the following does not:

vips_call('webpsave', $im, ['smart_subsample' => true]);

It produces the following error (received with vips_error_buffer()):

webpsave: no property named 'smart_subsample'

I get the same result when using vips_image_write_to_file and when using the webpsave method of \Jcupitt\Vips\Image

The following options works with webpsave: Q, lossless, strip
The following options does not work, and produces an error similar to above: preset, near_lossless, smart_subsample, alpha_q

I'm on:
vips version: 8.2.2, vips extension version: 1.0.9, ubuntu 16.04, apache, fpm

Trying to understand memory usage with php-fpm

We're using the php-vips-ext together with php-fpm for image manipulation of pictures, mainly for web usage (meaning, they're not huge). All works fine and fast now, but I'm trying to understand the memory usage.

If have currently set vips_cache_set_max_mem to 50MB and vips_cache_set_max_files to 100 (just as a first start). What I see now is that some php-fpm process are using way more than that after some time (the current max is 340MB), it was way less than that before.

I also see a value of 250MB in vips_tracked_get_mem_highwater (not sure that's the one corresponding to the 340MB using memory, but good enough for getting the idea), while vips_tracked_get_mem is around the 50MB.

Is something not releasing that highwater memory? Maybe PHP itself for performance reasons? I can circumvent it with just killing php-fpm after a few hundred requests, that's totally fine, I just try to understand what's happening.

btw, I use https://github.com/pixelb/ps_mem for getting the memory usage of a process, which seems pretty accurate.

SIGSEGV on OSX

[02-Dec-2017 00:15:55] WARNING: [pool www] child 1618 exited on signal 11 (SIGSEGV) after 55.787030 seconds from start

Is this a know issue ?

I use vips-8.5.9-Fri Dec 1 23:13:50 CET 2017

vips installed with brew and the php extension compile with pecl

OSX 10.13.1

Tested with PHP 7.1 and 7.2 it's pretty random, sometime everything work and it fast ... and sometimes just crash

Thanks

Opening pdf file

Hello, I am new to php-vips add on.
This functions working good.
$x = vips_image_new_from_file($file)["out"]; (any files tpyes jpg, png, pdf)
vips_image_write_to_file($x, "temp/$filename-to.png",["Q"=>90);

But how can I custom read load $img=vips_pdfload() or $img=vips_pngload() with php plugin.

$img=vips_call("pdfload","file.pdf"); not working; How can i use spefic 300 operations on php ?

8.12.2 Active php ext functions;

  | (
  | [0] => vips_image_new_from_file
  | [1] => vips_image_new_from_buffer
  | [2] => vips_image_new_from_array
  | [3] => vips_image_write_to_file
  | [4] => vips_image_write_to_buffer
  | [5] => vips_image_copy_memory
  | [6] => vips_image_new_from_memory
  | [7] => vips_image_write_to_memory
  | [8] => vips_image_write_to_array
  | [9] => vips_foreign_find_load
  | [10] => vips_foreign_find_load_buffer
  | [11] => vips_interpolate_new
  | [12] => vips_call
  | [13] => vips_image_get
  | [14] => vips_image_get_typeof
  | [15] => vips_image_set
  | [16] => vips_type_from_name
  | [17] => vips_image_set_type
  | [18] => vips_image_remove
  | [19] => vips_error_buffer
  | [20] => vips_cache_set_max
  | [21] => vips_cache_set_max_mem
  | [22] => vips_cache_set_max_files
  | [23] => vips_concurrency_set
  | [24] => vips_cache_get_max
  | [25] => vips_cache_get_max_mem
  | [26] => vips_cache_get_max_files
  | [27] => vips_cache_get_size
  | [28] => vips_concurrency_get
  | [29] => vips_version
  | )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.