Convert PNG to EPS using API for .NET

Overview

This article explains how to convert PNG to EPS using C#. It covers the following topics.

C# Image to EPS

The Image to EPS conversion using C# from other formats like BMP, TIFF, JPG etc. are covered in these articles.

C# PNG to EPS Conversion

You can check the quality of Aspose.Page PNG to EPS conversion and view the results via free online PNG to EPS Converter and than view the resulting EPS file with our EPS Viewer


Aspose.Page for .NET PNG to EPS converter allows to convert PNG image to Encapsulated PostScript (EPS) file with using of any language supported by .NET platform: C#, VB, J#.

Steps: PNG to EPS Converter API Code in C#

It is necessary to do just 2 steps in order to perform PNG to EPS conversion:

  1. Create an instance of PsSaveOptions.
  2. Use static method SaveImageToEps of PsDocument.

SaveImageToEps method has four modifications to provide a user with the most comfortable way to save PNG image to EPS.

Using strings for saving PNG to EPS in C#

In the following C# code snippet the input image and the output EPS file are assigned by strings:

1// Convert PNG image to EPS using files paths.
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6// Save PNG image to EPS file
7PsDocument.SaveImageAsEps(DataDir + "input.png", OutputDir + "output_png.eps", options);

Using streams for saving PNG to EPS in C#

In the following C# code snippet input image and output EPS file are assigned by streams:

 1// Convert PNG image to EPS using streams.
 2
 3// Create default options
 4PsSaveOptions options = new PsSaveOptions();
 5
 6// Create input stream from image
 7using (FileStream input = new FileStream(DataDir + "input.png", FileMode.Open))
 8{
 9    // Create output stream for EPS
10    using (FileStream output = new FileStream(OutputDir + "output_png.eps", FileMode.Open))
11    {
12        // Save PNG image from input file stream to EPS file output stream
13        PsDocument.SaveImageAsEps(input, output, options);
14    }
15}

Using Bimap object and string for saving PNG to EPS in C#

In the following C# code snippet input image is assigned by Bitmap object and the output EPS file is assigned by string:

 1// Convert PNG image to EPS from Bitmap object to file.
 2
 3// Create default options
 4PsSaveOptions options = new PsSaveOptions();
 5
 6using (Bitmap bmp = new Bitmap(DataDir + "input.png"))
 7{
 8    // Save PNG bitmap to EPS file
 9    PsDocument.SaveImageAsEps(bmp, OutputDir + "output_png.eps", options);
10}

For Linux, MacOS and other non-Windows operation systems we offer to use our Aspose.Page.Drawing Nuget package. It uses Aspose.Drawing backend instead of System.Drawing system library.

So import Aspose.Page.Drawing namespace instead of System.Drawing one. In the above and the following code snippets Aspose.Page.Drawing.Bitmap will be used instead of System.Drawing.Bitmap. Our code examples on GitHub contain all the necessary substitutions.

Using Bimap object and stream for saving PNG to EPS in C#

In the following C# code snippet input image is assigned by Bitmap object and the output EPS file is assigned by stream:

 1// Convert PNG image to EPS from Bitmap object to stream.
 2
 3// Create default options
 4PsSaveOptions options = new PsSaveOptions();
 5
 6using (Bitmap bmp = new Bitmap(DataDir + "input.png"))
 7{
 8    // Create output stream for EPS
 9    using (FileStream output = new FileStream(OutputDir + "output_png.eps", FileMode.Open))
10    {
11        // Save PNG bitmap to EPS file stream
12        PsDocument.SaveImageAsEps(bmp, output, options);
13    }
14}

See PNG to EPS conversion in Java and C++.

Evaluate PNG to EPS conversion online on our PNG to EPS Converter. You can convert several PNG image to EPS files at once and download the results in a few seconds.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.