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

Query Supported Image Formats #255

Open
olivervogel opened this issue Dec 29, 2024 · 3 comments
Open

Query Supported Image Formats #255

olivervogel opened this issue Dec 29, 2024 · 3 comments

Comments

@olivervogel
Copy link

Is there a way to list or query the supported image formats at runtime? Something along the lines of Imagick::queryFormats() at Imagick.

At the moment I get by by creating a temporary 1x1 image and trying to encode it into the format to check. However, this does not seem to be very resource-friendly.

Also see Intervention/image-driver-vips#17

@jcupitt
Copy link
Member

jcupitt commented Dec 29, 2024

Hello @olivervogel,

The libvips way is to use gobject introspection to find this. You walk the class hierarchy below VipsForeignLoad and find all the non-abstract classes, or perhaps the set of defined suffixes.

You can do this at the CLI with eg.:

$ vips -l load
      VipsForeignLoad (load), loaders, priority=0
        VipsForeignLoadCsv (csvload_base), load csv, priority=0, untrusted
          VipsForeignLoadCsvFile (csvload), load csv (.csv), priority=0, untrusted, get_flags, get_flags_filename, header, load
          VipsForeignLoadCsvSource (csvload_source), load csv, priority=0, untrusted, is_a_source, get_flags, header, load
        VipsForeignLoadMatrix (matrixload_base), load matrix, priority=0
          VipsForeignLoadMatrixFile (matrixload), load matrix (.mat), priority=0, is_a, get_flags, get_flags_filename, header, load
          VipsForeignLoadMatrixSource (matrixload_source), load matrix, priority=0, is_a_source, get_flags, header, load
        VipsForeignLoadRaw (rawload), load raw data from a file, priority=0, untrusted, get_flags, get_flags_filename, header
... etc.

In php-vips, you'd call vips_type_map(), though it'd need a bit of FFI calling. I'll try to make an example.

@olivervogel
Copy link
Author

Thanks @jcupitt

Could you show me some more details. I can't currently figure out how to get results with vips_type_map() and calling FFI. Many thanks in advance.

@jcupitt
Copy link
Member

jcupitt commented Jan 7, 2025

Sorry, not found the time to make some example code yet.

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

No branches or pull requests

2 participants