Issue when converting EPS to JPG

Hi All,

We tried to use above packages to convert .psd and .eps to jpg, but we are getting below errors.

My .Net Solutions:
Version: .Net 6
Deployed on Kubernetes pods - Linux container.
Language : C#

Psd file error:
Aspose.PSD.CoreExceptions.ImageSaveException: Image export failed.
—> System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
—> System.DllNotFoundException: Unable to load shared library ‘libgdiplus’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip…cctor()
— End of inner exception stack trace —
at System.Drawing.SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(IntPtr& fontCollection)
at System.Drawing.Text.PrivateFontCollection…ctor()

Eps Error:
System.TypeInitializationException : The type initializer for ‘Gdip’ threw an exception.
---- System.PlatformNotSupportedException : System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information.
Stack Trace:

Sample code i used to convert: Convert images EPS to BMP via C# | products.aspose.com

I am trying to analyze about above errors and found below details.

Is it possible to update these aspose dlls and release new version which will support Linux.

Thanks,
Sekhar

Hi All,
Could you please update on the above issue?
Thanks,
Sekhar

@rgksekhar9 please check the following article:

  1. It looks like that updating of dockerfile with following code should help.
RUN apt-get update
RUN yes | apt-get install -y apt-transport-https
RUN yes | apt-get install -y libgdiplus
RUN yes | apt-get install -y libc6-dev
  1. Also, you can try to use Aspose.PSD for .NET 7, it hasn’t dependency from System.Drawing

  2. If you you want to use .net 6, please check the following fix:

         // Fix of the unsupported System.Drawing.Common lib on OS X and .NET6.
         // Details: https://aka.ms/systemdrawingnonwindows
         System.AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
    

or

            "configProperties": {
                  "System.Drawing.EnableUnixSupport": true
            }

Could you please write me back if one of the ways to avoid issue helped?

Hi Dmitriy,
Thanks for your reply.

I have updated docker file and added setswitch in the eps conversion mehtod. Now am not getting any errors but am not seeing the image content also. Please refer attached file.

epsjpg.png (27.5 KB)

I am not able to upload .eps file which i have used to convert here.
Thanks,
Sekhar

@rgksekhar9 according to watermark in the left top corner, you use not Aspose.PSD, but Aspose.Imaging. Aspose.PSD doesn’t support converting from EPS to PSD. Maybe I should move this topic to Aspose.Imaging forum thread?

Do I need to use Aspose.PSD for .eps to .jpg conversion?

Do I need to use Aspose.PSD for .eps to .jpg conversion?

I have used below link to convert .eps to .jpg

If this is not correct please provide correct link/sample code to convert eps to jpg?

@rgksekhar9 for this conversion Aspose.Imaging is suitable. And documentation you provided is Aspose.Imaging documentation.

Ok, Please move it to Aspose.Imaging forum.

@rgksekhar9 if any Aspose.PSD team help will be needed, please mention me.

@samer.el-khatib could you please process this request.

1 Like

This is my code ----
public async Task<byte[]> DownloadAssetEPS([FromForm] IFormFile file, string format)
{
try
{
System.AppContext.SetSwitch(“System.Drawing.EnableUnixSupport”, true);
var ms = new MemoryStream();

      var msEPS = new MemoryStream();

      file.CopyTo(ms);

      ms.Seek(0, System.IO.SeekOrigin.Begin);

      if (format == "png") 
      {
          using (var image = Aspose.Imaging.Image.Load(ms))
          {
              var exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();

              image.Save(msEPS, exportOptions);
          }
      }
      else
      {
          using (var image = Aspose.Imaging.Image.Load(ms))
          {
              var exportOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

              image.Save(msEPS, exportOptions);
          }
      }

      await ms.DisposeAsync();

      return msEPS.ToArray();

  }
  catch (Exception ex)
  {
      throw ex;
  }

}

@rgksekhar9 , could you share the EPS sample causing an error? So we can investigate the issue.

GP1208871.zip (151.5 KB)

PFA…

Hi All,

Any update on the above issue?

Thanks,
Sekhar

Hi @Denis.Sitko ,

Please update me on the above issue.

Thanks,

@rgksekhar9 , let us review your request! You will be answered shortly!

@rgksekhar9 , We did not manage to reproduce error for EPS image above using Aspose.Imaging.23.11. Please check the version you are using.
Hope this helps!

Hi @Denis.Sitko
We are using below versions. And we are not getting any errors also.
We are seeing only watermark but not the actual image .


Please upload the image output.

Thanks,
Sekhar

Hi @Denis.Sitko ,

What’s wrong in these lines of code? Why we are not able to see the converted jpg image content?

This is my code ----
public async Task<byte[]> DownloadAssetEPS([FromForm] IFormFile file, string format)
{
try
{
System.AppContext.SetSwitch(“System.Drawing.EnableUnixSupport”, true);
var ms = new MemoryStream();

      var msEPS = new MemoryStream();

      file.CopyTo(ms);

      ms.Seek(0, System.IO.SeekOrigin.Begin);

      if (format == "png") 
      {
          using (var image = Aspose.Imaging.Image.Load(ms))
          {
              var exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();

              image.Save(msEPS, exportOptions);
          }
      }
      else
      {
          using (var image = Aspose.Imaging.Image.Load(ms))
          {
              var exportOptions = new Aspose.Imaging.ImageOptions.JpegOptions();

              image.Save(msEPS, exportOptions);
          }
      }

      await ms.DisposeAsync();

      return msEPS.ToArray();

  }
  catch (Exception ex)
  {
      throw ex;
  }

}

Thanks,