Crop and resize EPS

Native API Solution to manage size of EPS images via .NET

 

Transforming your EPS image just got easier! With Aspose.Page for .NET you can crop or change the size of EPS files to your exact specifications in a few lines of code. Want to make it larger? No problem. Need it smaller? We've got you covered. Our API for C# allows you to scale your image precisely, ensuring it fits your vision like a glove.

The technology is developed to work its magic on the image header and setup section of your EPS file, leaving the content untouched. This means your file size remains unchanged, making the process seamless and efficient. To resize your EPS image in C# you will first need to decide the following:

  • Determine the existing size of your image.

  • Choose the units that best suit your needs: Points (1/72 of an inch), Inches, Millimeters, Centimeters, or Percents.

Aspose.Page provides you with the functionality to manage the borders of EPS files easily. With this API you can scale or crop images using C#. To learn more about how to deal with EPS files follow the documentation. To see the live version of the functionality try EPS Crop and EPS Resize cross-platform apps.

To use the functionality you first need to get the solution:

  • Open the NuGet package manager, and search for Aspose.Page and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


    PM> Install-Package Aspose.Page

Steps to change the size of EPS image C#.

The example below shows the process of resizing .eps with the chosen units - points. The order is:

  1. Initialize the PsDocument object with an input stream containing an EPS file.
  2. Define the existing size of the image using the ExtractEpsSize() static method.
  3. Create an output stream for the resulting EPS file.
  4. Resize the PsDocument object with a new size in points with the ResizeEps() static method.
  5. Save the result file.

C# Code to resize EPS images (points).

    using Aspose.Page.EPS;
    using Aspose.Page.EPS.Device;
    // Set the path to the documents directory.
    string dataDir = GetDataDir();

    //Create an input stream for an EPS file
    using (Stream inputEpsStream = new System.IO.FileStream(dataDir + "input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read))
    {
        //Initialize the PsDocument object with the input stream
        PsDocument doc = new PsDocument(inputEpsStream);

        //Get the size of the EPS image
        Size oldSize = doc.ExtractEpsSize();

        //Create an output stream for the resized EPS
        using (Stream outputEpsStream = new System.IO.FileStream(dataDir + "output_resize_inches.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
        {
            //Save the EPS to the output stream with the new size assigned in inches
            doc.ResizeEps(outputEpsStream, new SizeF(oldSize.Width * 2, oldSize.Height * 2), Units.Points);
        }
    }



FAQ

1. Is it possible to crop EPS files?

EPS files are essentially PostScript files encapsulated within a bounding box, and they can be cropped by modifying the bounding box parameters to specify the desired region of the image. This process effectively trims away any unwanted areas of the EPS image.

2. How can I crop an Encapsulated PostScript file?

Aspose.Page lets you crop EPS files using the ExtractEpsSize() static Method to get the size of the actual file and crop it to a new size in points with the ResizeEps() static Method.

3. Are there any tools or software specifically designed for cropping EPS (Encapsulated PostScript) files?

Aspose.Page has EPS Crop cross-platform application that lets you crop files online in just a second.

EPS What is EPS File Format

EPS (EPSF) or Encapsulated PostScript File Format is the format that is actually a PS program that describes what would a single page look like. It is actually limited PS plus particular notes that help encapsulate PostScript graphics to another document. EPS perfectly supports vector graphics or combined vector-raster graphics. The peculiarity of the format is that as soon as it is imported into a document, it cannot be edited anymore. That is one of the reasons to convert this format to the one you are able to work with.