We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Converting from EMF to PNG does not work in linux

Howdy,

We have a license for Aspose.Imaging 20.3.0 and are trying to convert from EMF image to png. I’ll post the code below. This works when I run locally on my windows machine, but when its deployed to a linux server, it does not work.

using(var imgFile = new MemoryStream()){
            args.ImageStream = new MemoryStream();
            using(var image = Aspose.Imaging.Image.Load(args.MetafileStream)){
                if (image.FileFormat.Equals(Aspose.Imaging.FileFormat.Emf))
                {
                    Aspose.Imaging.ImageOptionsBase exportOptions = new PngOptions(){ ColorType = PngColorType.TruecolorWithAlpha};
                    VectorRasterizationOptions rasterizationOptions = new EmfRasterizationOptions();
                    rasterizationOptions.PageWidth = image.Width;
                    rasterizationOptions.PageHeight = image.Height;
                    exportOptions.VectorRasterizationOptions = rasterizationOptions;
                    imgFile.Seek(0, SeekOrigin.Begin);
                    image.Save(imgFile, exportOptions);
                }
                imgFile.Position = 0;
                imgFile.CopyTo(args.ImageStream);
            }
            
        }

The error is
ArgumentException: new Bitmap(7411, 879) caused Aspose.Rendering.ApsCanvas : Aspose.Rendering.ApsCanvas : Aspose.Rendering.ApsCanvas : Aspose.Rendering.ApsCanvas : Out of memory.[ at System.Drawing.Graphics.SetClip(Region region, CombineMode combineMode)
at .( )
at . (ApsCanvas )
at Aspose.Rendering.ApsCanvas.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )][ at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCanvas.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )][ at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCanvas.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )][ at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCanvas.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )
at Aspose.Rendering.ApsCompositeNode.3zcv74pe4aak5l7le8hzs4ef5p5bmay8 ( )]

@dmerkle1 You can try to specify the BufferSizeHint in the load options to reduce memory consumption. Please note that the buffer size hint is in megabytes, e.g. you can set it to 128 for 128MB.

Appreciate you reaching out. That did not work, but we did try a free version of the newest image library, and that did work.