Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vips_foreign_find_load missing #37

Closed
kleisauke opened this issue Mar 10, 2017 · 5 comments
Closed

vips_foreign_find_load missing #37

kleisauke opened this issue Mar 10, 2017 · 5 comments

Comments

@kleisauke
Copy link
Member

In order to pass the correct options before the Image::newFromFile operation, the vips_foreign_find_load will come in handy to determine the image format.

Example:
The page property works only for PDFs, TIFFs, and multi-size ICOs (or any other image that has more than one page). But doesn't work for a JPEG (it will fail with the error: Message: jpegload: no property named 'page'). In order to pass the page property to the correct loader we can check first with vips_foreign_find_load if the operation permits a page property.

@jcupitt
Copy link
Member

jcupitt commented Mar 10, 2017

I agree, I think it'd be a useful improvement. We should add the one for buffers as well, I guess.

In the meantime, you could just open the file and look at the vips-loader property. It records the name of the load operation that was used:

$ vipsheader -f vips-loader k2.jpg 
jpegload

So open once, get loader name, open a second time with whatever arguments you want.

@jcupitt
Copy link
Member

jcupitt commented Mar 13, 2017

OK, in git master. Thanks!

@jcupitt jcupitt closed this as completed Mar 13, 2017
@jcupitt
Copy link
Member

jcupitt commented Mar 13, 2017

git master php-vips has a wrapper as well, with a fallback to the property method:

https://github.com/jcupitt/php-vips/blob/master/src/Image.php#L716

and a version for buffers.

@kleisauke
Copy link
Member Author

Nice! Travis is currently failing because the newest version of php-vips-ext isn't on PECL yet, I think we can ignore it for now.

@jcupitt
Copy link
Member

jcupitt commented Mar 13, 2017

OK, fixed travis. It turns out you can't catch undefined functions :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants