Thanks to visit codestin.com
Credit goes to github.com

Skip to content

magick6load: merge with magick2vips.c #4375

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

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

kleisauke
Copy link
Member

Context: #4249 (comment).

Split out from #4249.

@jcupitt jcupitt merged commit 02e954e into libvips:master Mar 17, 2025
6 checks passed
@jcupitt
Copy link
Member

jcupitt commented Mar 17, 2025

I agree this needs doing. Thje old magick2vips.c was there to support vips7 compatibility -- deprecated/im_magick2vips.c has:

int 
im_magick2vips(const char *filename, IMAGE *out)
{
#ifdef HAVE_MAGICK
    /* Old behaviour was always to read all frames.
     */
    return vips__magick_read(filename, out, NULL, 0, -1);
#else
    vips_error("im_magick2vips",
        "%s", _("no libMagick support in your libvips"));

    return -1;
#endif /*HAVE_MAGICK*/
}

Which (I think) will no longer work correctly. It should maybe be HAVE_MAGICK6 || HAVE_MAGICK7, but vips__magick_read() isn't there any more anyway, so it wouldn't compile.

Now we have nip4 it's tempting to get rid of vips7 compatibility, but maybe we should keep it a bit longer.

Perhaps the simplest fix would be to change im_magick2vips to be (eg. untested!):

int 
im_magick2vips(const char *filename, IMAGE *out)
{
    VipsImage *t;

    if (!(t = vips_magickload(filename, "n", -1, NULL)))
        return -1;
    if (vips_image_write(t, out)) {
        VIPS_UNREF(t);
        return -1;
    }
    VIPS_UNREF(t);

    return 0;
}

That won't perform well, but it would let old code compile and run.

@kleisauke kleisauke deleted the magick6load-merge branch March 17, 2025 14:44
@kleisauke
Copy link
Member Author

Nice catch! It looks like the registration of *magick formats in the vips7 compatibility layer also needs to be updated:

#ifdef HAVE_MAGICK
extern GType vips_format_magick_get_type(void);
vips_format_magick_get_type();
#endif /*HAVE_MAGICK*/

I'll open a follow-up PR for this shortly.

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.

2 participants