Resize EPS | Node.js API Solution

Overview

This article explains how to resize EPS using Node.js. It covers the following topics.

Node.js Resize EPS Description

When you resize an image, you’re adjusting its width, height, or both. The image’s core content stays the same, but its appearance scales based on the new dimensions. If you increase both the width and height proportionally, the EPS image will be enlarged; otherwise, it’ll become smaller. Changing the width and height disproportionately will either compress or stretch the EPS image in a particular direction. The good news is that the EPS file’s size will stay largely the same, since our solution modifies only the file’s header and setup section, not the image content itself.

To effectively set a new size for an EPS image, you’ll often need to know its current dimensions. You’ll also need to pick the units for the new size, which can include Points (1/72 of an inch), Inches, Millimeters, Centimeters, and Percents.

So the steps for resizing EPS image in Node.js follows:

  1. Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
  2. On load event handler call AsposeResizeEPS and pass the file content and its name, new size as width and height, and unit type to it.
  3. The result JSON contains the file name in fileNameResult.
  4. You can download fa ile by using the DownloadFile function: ‘DownloadFile(JSON.fileNameResult, “image/pdf”);’.

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


Resize EPS setting new size in Points in Node.js

In the following Node.js code snippet new size of the image is set by Points (1/72 of inch):

 1const AsposePage = require('asposepagenodejs');
 2
 3const eps_file = "./data/PAGENET-361-10.eps";
 4
 5console.log("Aspose.Page for Node.js via C++ examples.");
 6
 7AsposePage().then(AsposePageModule => {
 8
 9    //ResizeEPS - working with EPS
10    const JSON = AsposePageModule.AsposeResizeEPS(eps_file, "resized.eps", 200, 100, AsposePageModule.Units.Points);
11    console.log("ResizeEPS => %O",  JSON.errorCode == 0 ? JSON.parse(JSON.stringify(JSON).replace('"errorCode":0,"errorText":"",','')) : JSON.errorText);
12
13},
14    reason => {console.log(`The unknown error has occurred: ${reason}`);}
15);

See Resize EPS in Java and C++.

Initial EPS Image


Initial image

Resized EPS Image


Resized image

Evaluate resizing EPS online on our Resize EPS web application. You can resize the EPS file and download the result 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.