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

MagickCorruptImageErrorException: Wrong JPEG library version: library is 80, caller expects 62 #1472

Closed
ccremer opened this issue Oct 27, 2023 · 7 comments

Comments

@ccremer
Copy link

ccremer commented Oct 27, 2023

Magick.NET version

"Magick.NET-Q8-x64" Version="13.4.0"

Environment (Operating system, version and so on)

Linux (Mint 21.2 (Ubuntu-Based))

Description

While trying to resize an image on Linux, this error pops up:

      ImageMagick.MagickCorruptImageErrorException: Wrong JPEG library version: library is 80, caller expects 62 `/redacted/image00833.jpg' @ error/jpeg.c/JPEGErrorHandler/348
         at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) in /_/src/Magick.NET/Native/NativeInstance.cs:line 57
         at ImageMagick.MagickImage.NativeMagickImage.ReadFile(IMagickSettings`1 settings) in /_/src/Magick.NET/Native/MagickImage.cs:line 6983
         at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings, Boolean ping) in /_/src/Magick.NET/MagickImage.cs:line 7623
         at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4906
         at ImageMagick.MagickImage.Read(FileInfo file, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4817
         at ImageMagick.MagickImage.Read(FileInfo file) in /_/src/Magick.NET/MagickImage.cs:line 4778
         at ImageMagick.MagickImage..ctor(FileInfo file) in /_/src/Magick.NET/MagickImage.cs:line 117

It seems like something is missing with the dependencies.

Steps to Reproduce

Not sure how to reproduce this, seems like it's caused by something related to the installation.
Code-wise I'm resizing an image with this method:

    private async Task Resize(string inputImagePath, string outputImagePath, int width, int height, CancellationToken ctx)
    {
        logger.LogTrace("Resizing image '{InputImagePath}' to '{OutputImagePath}' with {Width}x{Height}", inputImagePath, outputImagePath, width, height);

        var magickImage = new MagickImage(new FileInfo(inputImagePath));
        magickImage.Resize(width, height);
        await magickImage.WriteAsync(outputImagePath, ctx);
    }
@dlemstra
Copy link
Owner

Is it possible to create a Dockerfile that can be used to reproduce this issue?

@ccremer
Copy link
Author

ccremer commented Oct 27, 2023

Hm, not sure. I guess it depends heavily on the base image and their packages, though I can try to investigate next week again.

@dlemstra
Copy link
Owner

Can you still reproduce the issue when you use using var magickImage instead?

@ccremer
Copy link
Author

ccremer commented Oct 30, 2023

Can you still reproduce the issue when you use using var magickImage instead?

Unfortunately yes

@ccremer
Copy link
Author

ccremer commented Oct 30, 2023

I've found out more.
The problem is somewhat related to #1471 . When I disable the IronPDF dependency, then it works 🤷
So I guess that Magick and IronPDF are somewhat incompatible. IronPDF ships with a chrome binary which is itself dependent on glib and doing something with jpeg.

I try to find out more to isolate the error.

@dlemstra
Copy link
Owner

I really wonder what they are doing internally but I suspect that you will need to figure that out with them yourself. Their library is not open source so you probably need to your account manager at IronSoftware. The Magick.NET library is statically linked so I don't understand how they can break things in my implementation. That really sounds like so strange magic. Maybe they are also using Magick.NET?

@ccremer
Copy link
Author

ccremer commented Oct 31, 2023

I agree.
It gets even worse: I built a Dockerfile based on ubuntu:22.04 and even linuxmintd/mint21.2-amd64 and I was NOT able to reproduce the issue 🤷 I have to come to the conclusion that this problem is actually on my system only (some incompatibility between glib or anything, who knows what I've already installed on my dev machine? ;) ). It looks like I can only use either IronPDF or MagickNET, but not both. But I don't have the time to further investigate this rabbit hole, so I'll use a workaround to call the convert binary via feature flag in our app.

I am closing this as it's not reproducible. Thanks for your support.

@ccremer ccremer closed this as completed Oct 31, 2023
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