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

iTXt: chunk data is too large after removing XMP data using Adobe XMP Toolkit #236

Closed
dashkan opened this issue Jun 5, 2018 · 4 comments

Comments

@dashkan
Copy link

dashkan commented Jun 5, 2018

Hi,

I have a PNG with a lot of of XMP metadata (8MB+). After removing some of the metadata using Adobe XMP Toolkit I get the following exception:

Unhandled Exception: ImageMagick.MagickCoderErrorException: iTXt: chunk data is too large `E:\images\blank_after.png' @ error/png.c/MagickPNGErrorHandler/1711

Here is a link to the file that is used prior to removing XMP metadata:

And a link to the file after the removing the XMP metadata.

I am able to open the file using Adobe Photoshop and other image editors.

Adobe XMP Toolkit does not reduce the file size after removing metadata, I wanted to open / save using Magick.NET to reduce the file size.

Looks like a dup of #105.

I am using Magick.NET-Q16-HDRI-AnyCPU 7.4.6.0

@dlemstra
Copy link
Owner

Sorry for the late response but I completely forgot about this issue.

It looks like you are running into a limit inside the libpng library. The size of your iTXt chunk is larger than that limit. At this moment we have no method to change/remove this limit but I will try to add that later this week. I was about to publish a new release but I will wait with that and add this feature to ImageMagick (and Magick.NET) first.

@dlemstra
Copy link
Owner

The feature has been added and you can read the file in the next release with the following code:

var settings = new MagickReadSettings()
{
    Defines = new PngReadDefines()
    {
        ChunkMallocMax = 0, // Unlimited
    },
};

using (var image = new MagickImage("YourFile.png", settings))
{
    image.Read(Files.SnakewarePNG, settings);
}

@dlemstra
Copy link
Owner

The new release has been published, can you give it another try @ashkandaie?

@dashkan
Copy link
Author

dashkan commented Jun 26, 2018

@dlemstra

Thanks for the fix. I am able to read PNGs w/ large XMP payloads.

Keep up the good work!

@dashkan dashkan closed this as completed Jun 26, 2018
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