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

Add support for ImageMagick version 7 #2258

Merged
merged 1 commit into from
Jun 15, 2020
Merged

Conversation

vouillon
Copy link
Contributor

libvips uses specific loaders for ImageMagick 7.

libvips uses specific loaders for ImageMagick 7.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0f5054f on besport:imagemagick-7 into 0f58f95 on lovell:master.

@lovell lovell merged commit 4470048 into lovell:master Jun 15, 2020
@lovell
Copy link
Owner

lovell commented Jun 15, 2020

La magie, merci/thanks!

@jcupitt
Copy link
Contributor

jcupitt commented Aug 8, 2020

This is not very important, but checking for the exact class names feels a little ugly, and could break.

How about checking the nickname instead? The libvips base object has a nickname class member:

https://github.com/libvips/libvips/blob/master/libvips/include/vips/object.h#L525

It's also exposed as an object member and glib property on vips objects. The nickname is the thing that's used to look up operations by name, eg.:

GType vips_type_find( const char *basename, const char *nickname );
const char *vips_nickname_find( GType type );

vips_type_find uses a lazy hash to go from a nickname to a GTypeefficiently.

In this case you could use:

char const *load = file ? vips_foreign_find_load(file) : NULL;
GType gtype = load ? g_type_from_name(load) : 0;
const char *nickname = gtype ? vips_nickname_find(gtype) : NULL;

And nickname will be something like magickload or NULL. libvips guarantees that nicknames are unique and unvarying, ie. they are a supported part of the API (unlike class names, which are not). You could perhaps use a hash to map nicknames to file types and save the switch.

@jcupitt
Copy link
Contributor

jcupitt commented Aug 8, 2020

... I could try a PR, if that would help.

@lovell
Copy link
Owner

lovell commented Aug 9, 2020

@jcupitt Great idea, thank you, I've added this via commit 8da30f0

@jcupitt
Copy link
Contributor

jcupitt commented Aug 9, 2020

Ah, much prettier! Nice!

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

Successfully merging this pull request may close these issues.

4 participants