EMF to PNG image conversion issue on Linux

Hi Team!

We are extracting images from PowerPoint documents and if the embedded image is a WMF/EMF image we convert it to PNG.

On Linux environment we noticed that some of the texts are overlapping on the PNG image after the conversion and some parts of the text are outside of the image boundaries. On Windows it is working fine.

Could it be a font issue or something else?

The Linux environment:

  • OS: Ubuntu 20.04.2 LTS
  • Aspose.Imaging version: 21.2.0
  • .Net Core SDK version: 3.1.406
  • .Net Core Runtime version: 3.1.12
  • ttf-mscorefonts-installer is also installed

.Net Core Project:
ProcessPresentationImages.zip (2.5 KB)

Test files:
sample_files.zip (2.0 MB)

Extracted and converted images:
extracted_images_as_png.zip (728.4 KB)

List of installed fonts:
font_info.zip (1.2 KB)

@erdeiga

It seems to be more of a font related issue. However, I have created a ticket with ID IMAGINGNET-4356 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

1 Like

There is another issue when I converting WMF image to PNG. After I load the wmf image I noticed that the image Height value is a negative number and it will throw an exception.

I can use the Math.Abs function for a quick fix but I think this is not the expected behavior. Am I right?

Aspose.Imaging.CoreExceptions.ImageSaveException: Image saving failed.
 ---> Aspose.Imaging.CoreExceptions.ImageSaveException: Image export failed.
 ---> System.ArgumentOutOfRangeException: Page size incorrect. Please specify positive values for WmfRasterizationOptions.PageWidth and WmfRasterizationOptions.PageHeight. (Parameter 'options')
   at          (VectorRasterizationOptions )
   at   .[T](VectorRasterizationOptions )
   at  .(Object )
   at  .(Object )
   at  .(MethodBase , Boolean )
   at  .  (  ,   )
   at  .()
   at  .(Boolean )
   at  .(Object )
   at  .(Object )
   at  .()
   at  .(Object , UInt32 )
   at  .(Boolean )
   at  .(Object[] , Type[] , Type[] , Object[])
   at  .(Stream , String , Object[] , Type[], Type[] , Object[] )
   at  .(Stream , String , Object[] )
   at           (VectorRasterizationOptions , Rectangle )
   at Aspose.Imaging.FileFormats.Wmf.WmfImage.kdpagfj68j63c55yfyctsx59qssnqmta    (ImageOptionsBase ,     , Rectangle )
   at    .(VectorImage , ImageOptionsBase , Rectangle )
   at    .       ( , Image , Stream , ImageOptionsBase, Rectangle , Rectangle )
   at    .Export(Image , Stream , ImageOptionsBase , Rectangle)
   at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   --- End of inner exception stack trace ---
   at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
   --- End of inner exception stack trace ---
   at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
   at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options)

Project:
ProcessPresentationImages.zip (2.5 KB)

Sample file:
embeddedOleObjects.zip (991.1 KB)

@erdeiga

I have observed the issue and we need to investigate it further on our end. A ticket with ID IMAGINGNET-4372 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

1 Like

@erdeiga

We couldn’t reproduce issue using latest version. Can you please provide extracted image file instead of embeddedOleObjects.pptx?

@erdeiga

Can you please share the following information so that we may proceed further with investigation on our end.

@mudassir.fayyaz,

Sorry for the late answer.

The exception only occurs when I trying to convert the memory stream of the Aspose.Slides IPPImage.BinaryData property. After I load it with Aspose.Imaging from MemoryStream the page size will be {Width=1048, Height=-795}.

When I extract and save the wmf image to wmf format there is no problem with the conversion (wmf to png) because after the Aspose.Imaging load from FileStream the page size will be {Width=1880, Height=999}

Maybe this could be an Aspose.Slides issue?

Extracted images:
extracted_images.zip (437.4 KB)

Aspose.Imaging version: 21.4.0
Aspose.Slides version: 21.4.0

@erdeiga

With your this elaboration, it doesn’t seems to be Aspose.Imaging issue and you may share the similar in Aspose.Slides forum as well.

@erdeiga

  1. Please install on the Linux package libgdiplus version 6.0.5 or higher
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt-get update 
sudo apt-get install -y libgdiplus libc6-dev libx11-dev libfontconfig1 xfonts-utils
  1. Add the required fonts to any folder, e.g. “Fonts”

  2. Execute the following code

    FontSettings.SetFontsFolder(“Fonts”);
    using (var image = Aspose.Imaging.Image.Load(“0.emf”))
    {
    image.Save(“result.png”, new PngOptions());
    }

result.png (106.9 KB)
Fonts.zip (1.1 MB)
0.emf.zip (2.3 KB)

@erdeiga

Can you please share if we may close the issue on our end or there is any further feedback in this regard from your side.

Hi @mudassir.fayyaz,
Sorry for the late response. If I set the font folder the text are not overlapping. Thanks for the advise.

So how does this SetFontsFolder is working?

If I set a specific folder only those fonts that are in this directory will be used during image conversion or this will append those font to some sort of global list?

@erdeiga

They will append to existing global fonts list but only for the time your program is under execution as they only have scope till program life.

The issues you have found earlier (filed as IMAGINGNET-4372) have been fixed in this update.