No pixels defined in cache for some PDF's
See original GitHub issueDescription
When using the Ping
command on a specific PDF asset, the following exception is raised:
Exception Message: no pixels defined in cache `C:/Users/KDECON~1/AppData/Local/Temp/magick-igIAnLjjffRbTW8Wg69TDYJeHOBYM2i41’ @ error/cache.c/OpenPixelCache/3682
Stacktrace: 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 5309 at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings, Boolean ping) in /_/src/Magick.NET/MagickImage.cs:line 7258 at ImageMagick.MagickImage.Ping(String fileName, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4717 at ImageMagick.MagickImage.Ping(String fileName) in //src/Magick.NET/MagickImage.cs:line 4708 at Program.<<Initialize>>d__0.MoveNext() in :line 8
Steps to Reproduce
Upload the following asset file: asset.pdf Ensure that GhostScript is installed on your machine. I’m using GhostScript 9.04 (but it can be reproduced on machine running GhostScript 9.54 as well) - Other versions have not been tested. Use the following RoslynPad script to reproduce the error. _NOTE: Change the path of the actual PDF to the correct location.
#r "nuget:Magick.NET-Q16-AnyCPU/8.5.0"
var image = @"C:\Temp\asset.pdf";
var imageMagickImage = new ImageMagick.MagickImage();
try
{
imageMagickImage.Ping(image);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
System Configuration
- Magick.NET version: 8.5.0 - But can be reproduced with version 7.23.2.1 - Other versions have not been tested.
- Environment (Operating system, version and so on): Microsoft Windows 10 Professional - Version 10.0.19043 Build 19043.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Good point. I think my patch broke that now. Will need to check if I can still add that though.
You will not be able to get the information because we don’t return an image and it’s information when an error occurs.
Are you testing this with the same
asset.pdf
file? The version that you are using (6.7.4
) is an ancient version of ImageMagick that should not be used anymore. I don’t understand why you don’t get an error with that old version. Maybe you are also using a different version of Ghostscript there?