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

NegativeOrZeroImageSize generated on Ubuntu 24.02, Net6 app, Ghostscript 10.03.1 or 10.04.0 #1787

Open
yfjjacob opened this issue Jan 17, 2025 · 3 comments

Comments

@yfjjacob
Copy link

Magick.NET version

Magick.NET-Q16-AnyCPU

Environment (Operating system, version and so on)

Ubuntu 24.04.1 LTS, dotnet version: 6.0.136

Description

I'm currently running into an issue with Magick.net-q16-anycpu(14.4.0) added as a nuget package to .net6 application run on Ubuntu 24.04 LTS with GhostScript 10.03.1 and 10.04.0

When I run the same code, on Visual Studio on a Windows machine with the same GhostScript version, it runs fine and images are produced as needed.

As a note, I have been running this code on a prior version on Ubuntu 22 and that worked fine. This issue happened after I upgraded the Nuget packages and GhostScript.

Any thoughts on what could be causing this?

Am attaching a sample pdf that's having this issue.

Type: ImageMagick.MagickErrorException
Message: The operation returned null but did not raise an exception.
StackTrace:    at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) in /_/src/Magick.NET/Native/NativeInstance.cs:line 60
   at ImageMagick.MagickImage.NativeMagickImage.ReadFile(IMagickSettings`1 settings) in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/MagickImage.g.cs:line 6074
   at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings, Boolean ping) in /_/src/Magick.NET/MagickImage.cs:line 7752
   at ImageMagick.MagickImage.Read(String fileName, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4846
   at ImageMagick.MagickImage..ctor(String fileName, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 222


Type: ImageMagick.MagickCorruptImageErrorException
Message: NegativeOrZeroImageSize `/media/fsdev/thumbnails/Decrypted/QA1/SR/9E1268C1-A5B8-4F7F-BD89-3F374625E5AC/6bf84dc4-07e7-4000-a416-53fb60d25c60.png' @ error/image.c/CloneImage/815
StackTrace:    at ImageMagick.MagickExceptionHelper.Check(IntPtr exception) in /_/src/Magick.NET/Exceptions/MagickExceptionHelper.cs:line 18
   at ImageMagick.NativeHelper.CheckException(IntPtr exception) in /_/src/Magick.NET/Native/NativeHelper.cs:line 20
   at ImageMagick.MagickImage.NativeMagickImage.WriteFile(IMagickSettings`1 settings) in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/MagickImage.g.cs:line 6637
   at ImageMagick.MagickImage.Write(String fileName) in /_/src/Magick.NET/MagickImage.cs:line 7147

Dotnet Info:

.NET SDK (reflecting any global.json):
 Version:   6.0.136
 Commit:    d638663530

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  24.04
 OS Platform: Linux
 RID:         ubuntu.24.04-x64
 Base Path:   /usr/lib/dotnet/sdk/6.0.136/

global.json file:
  Not found

Host:
  Version:      6.0.36
  Architecture: x64
  Commit:       f1dd57165b

.NET SDKs installed:
  6.0.136 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Steps to Reproduce

Here's the code I wrote. Substituted some variables with dummies here but basically the same thing. The error happens at document.Write.

testfile.pdf

int startIndex = 0;
  int pageCount = 2;
  Parallel.For(startIndex, pageCount, new ParallelOptions { MaxDegreeOfParallelism = 4 }, pageIndex =>
  {
    
      MagickReadSettings settings = new MagickReadSettings()
      {
          FrameIndex = Convert.ToUInt32(pageIndex),
          Density = new Density(68),
        
      };

      try
      {
          using (MagickImage document = new MagickImage(filePath, settings))
          {
             
              string thumbnailFileName = $"Image{pageIndex}.png"
              string outputPath = Path.Combine(outputDirectory, thumbnailFileName);             

              document.Write(outputPath);

          }

      }
      catch (MagickException ex)
      {
	Log(ex)
      }   
  });
@dlemstra
Copy link
Owner

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

@yfjjacob
Copy link
Author

Hi,

Sorry about the delay in response. I haven't worked with Docker or Dockerfiles before. Would you be able to clarify what you needed in the file?

@dlemstra
Copy link
Owner

With a Dockerfile it would be easier to create a sample that reproduces the issue. Because this allows you to create a "server" that is running the correct os and use the correct dotnet version. I can probably create this myself but it would make it easier for me if you would create that.

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