Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 26, 2025 13:46
Show Gist options
  • Select an option

  • Save aspose-com-gists/d6ab5365495f389c9b26cd71e28abac6 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/d6ab5365495f389c9b26cd71e28abac6 to your computer and use it in GitHub Desktop.
Resize EPS with .NET

Resize EPS Examples

These snippets illustrate obtaining the size and bounding box of an EPS image, resizing and cropping the EPS with Aspose.Page for .NET. Adjust artwork dimensions in different measure units, scale proportionally, or crop to specific rectangles while preserving vector quality.

Key Use Cases

  • Get the original size and resize the EPS to the target width/height assigned in points.
  • Obtain the existing size and resize EPS, assigning new dimensions in inches.
  • Get the original size and resize the EPS with the new width/height assigned in millimeters.
  • Obtain the existing size and resize EPS, assigning new dimensions as a percentage of the original ones.
  • Get the original bounding box and the top EPS to a region of interest.

How to Run Examples

  1. Reference Aspose.Page for .NET: Aspose.Page on Windows; Aspose.Page.Drawing on non‑Windows.
  2. Copy a snippet into your project or run the related test.
  3. Apply a temporary license as described in the licensing guide.
  4. Build and run.

Restrictions

In evaluation mode, the input EPS file is limited to 500Kb. Apply a valid license to enable full functionality.

Related Documentation

Further information about resizing and cropping EPS can be found in Resize EPS | .NET API Solution and Crop EPS | C# .NET API Solution chapters of the public documentation.

Related Resources

Requirements

  • .NET 6.0+, .NET Core, or .NET Framework
  • Aspose.Page for .NET library
Aspose.Page for .NET – Resize EPS Examples
// Cropping EPS file.
// Learn more: https://docs.aspose.com/page/net/crop-eps/
// Initialize PS document with EPS file
PsDocument document = new PsDocument(DataDir + "input.eps");
string outputFileName = "output_crop.eps";
//Get initial bounding box of EPS image
int[] initialBoundingBox = document.ExtractEpsBoundingBox();
//Create new bounding box
//Bounding box is represented by 4 numbers: x0, y0, x, y, where x0 - left margin, y0 - top margin, x - (x0 + width), y - (y0 + height)
float[] newBoundingBox = new float[] { 260, 300, 480, 432 };
//Crop EPS image and save to the output stream
//Croping of image is changing of its bounding box so that new values of bounding box will be within initial bounding box, that is
//initialBoundingBox[0] <= newBoundingBox[0] <= initialBoundingBox[2]
//initialBoundingBox[1] <= newBoundingBox[1] <= initialBoundingBox[3]
//initialBoundingBox[0] <= newBoundingBox[2] <= initialBoundingBox[2]
//initialBoundingBox[1] <= newBoundingBox[3] <= initialBoundingBox[3]
document.CropEps(OutputDir + outputFileName, newBoundingBox);
// Setting new size of EPS file in inches.
// Learn more: https://docs.aspose.com/page/net/resize-eps/#c-resize-eps-inches
// Initialize PS document with EPS file
PsDocument document = new PsDocument(DataDir + "input.eps");
string outputFileName = "output_resize_inches.eps";
//Get size of EPS image
Size oldSize = document.ExtractEpsSize();
//Save EPS file with new name and new size assigned in inches
document.ResizeEps(OutputDir + outputFileName, new SizeF(5.791f, 3.625f), Units.Inches);
// Setting new size of EPS file in millimeters.
// Learn more: https://docs.aspose.com/page/net/resize-eps/#c-resize-eps-mms
// Initialize PS document with EPS file
PsDocument document = new PsDocument(DataDir + "input.eps");
string outputFileName = "output_resize_mms.eps";
//Get size of EPS image
Size oldSize = document.ExtractEpsSize();
//Save EPS file with new name and new size assigned in millimeters
document.ResizeEps(OutputDir + outputFileName, new Size(196, 123), Units.Millimeters);
// Setting new size of EPS file in percents of original size.
// Learn more: https://docs.aspose.com/page/net/resize-eps/
// Initialize PS document with EPS file
PsDocument document = new PsDocument(DataDir + "input.eps");
string outputFileName = "output_resize_percents.eps";
//Get size of EPS image
Size oldSize = document.ExtractEpsSize();
//Save EPS file with new name and new size assigned in percents of original size
document.ResizeEps(OutputDir + outputFileName, new SizeF(200, 200), Units.Percents);
// Setting new size of EPS file in points.
// Learn more: https://docs.aspose.com/page/net/resize-eps/#c-resize-eps-points
// Initialize PS document with EPS file
PsDocument document = new PsDocument(DataDir + "input.eps");
string outputFileName = "output_resize_points.eps";
//Get size of EPS image
Size oldSize = document.ExtractEpsSize();
//Increase EPS size in 2 times and save to new file
document.ResizeEps(OutputDir + outputFileName, new SizeF(oldSize.Width * 2, oldSize.Height * 2), Units.Points);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment