Adjust EPS images via Java
Build your own Java apps to Adjust EPS image files using server-side APIs
How to Adjust EPS Files Using Java
Even the most experienced photographers can make mistakes or encounter unfavorable lighting conditions during a shoot. Such situations can lead to image defects, but even a bad photo has a chance. With the Java library, you can programmatically correct these issues by adjusting brightness, contrast, and color gamma. If a photo turns out too dark, increasing the brightness will lighten the dark areas, making previously hidden details visible. Adjusting contrast increases the difference between light and dark areas, expanding the brightness range for an improved image. If you’ve captured a photo under artificial lighting resulting in an unwanted color hue, utilize the color gamma adjustment to correct the white balance. In order to Adjust EPS files, we’ll use Aspose.Imaging for Java API which is a feature-rich, powerful and easy to use image manipulation and conversion API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging</artifactId>
<version>version of aspose-imaging API</version>
<classifier>jdk16</classifier>
</dependency>
Steps to Adjust EPS via Java
You need the aspose-imaging-version-jdk16.jar to try the following workflow in your own environment.
- load EPS files with Image.Load method;
- adjust image;
- save adjusted image to disc in the supported by Aspose.Imaging format.
System Requirements
Aspose.Imaging for Java is supported on all major operating systems. Just make sure that you have the following prerequisites.
- JDK 1.6 or higher is installed.
Adjust EPS images - Java
import com.aspose.imaging.IMultipageImage; | |
import com.aspose.imaging.Image; | |
import com.aspose.imaging.RasterImage; | |
import com.aspose.imaging.imageoptions.PngOptions; | |
import java.io.File; | |
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.function.Consumer; | |
adjustBrightness(); | |
public static void adjustGammaRGB() | |
{ | |
filterImages(image -> | |
{ | |
//https://apireference.aspose.com/imaging/java/com.aspose.imaging/RasterImage#adjustGamma-float-float-float- | |
image.adjustGamma(5, 0.1f, 0.1f); | |
}, "adjustgammargb"); | |
} | |
public static void adjustGamma() | |
{ | |
filterImages(image -> | |
{ | |
//https://apireference.aspose.com/imaging/java/com.aspose.imaging/RasterImage#adjustGamma-float- | |
image.adjustGamma(3); | |
}, "adjustgamma"); | |
} | |
public static void adjustContrast() | |
{ | |
filterImages(image -> | |
{ | |
//https://apireference.aspose.com/imaging/java/com.aspose.imaging/RasterImage#adjustContrast-float- | |
image.adjustContrast(50); | |
}, "adjustcontrast"); | |
} | |
public static void adjustBrightness() | |
{ | |
filterImages(image -> | |
{ | |
//https://apireference.aspose.com/imaging/java/com.aspose.imaging/RasterImage#adjustBrightness-int- | |
image.adjustBrightness(100); | |
}, "adjustbrightness"); | |
} | |
static String templatesFolder = "D:\\"; | |
public static void filterImages(Consumer<RasterImage> doFilter, String filterName) | |
{ | |
List<String> rasterFormats = Arrays.asList("jpg", "png", "bmp", "apng", "dicom", | |
"jp2", "j2k", "tga", "webp", "tif", "gif", "ico"); | |
List<String> vectorFormats = Arrays.asList("svg", "otg", "odg", "eps", "wmf", "emf", "wmz", "emz", "cmx", "cdr"); | |
List<String> allFormats = new LinkedList<>(rasterFormats); | |
allFormats.addAll(vectorFormats); | |
allFormats.forEach( | |
formatExt -> | |
{ | |
String inputFile = templatesFolder + "template." + formatExt; | |
boolean isVectorFormat = vectorFormats.contains(formatExt); | |
//Need to rasterize vector formats before background remove | |
if (isVectorFormat) | |
{ | |
inputFile = rasterizeVectorImage(formatExt, inputFile); | |
} | |
String outputFile = templatesFolder + String.format("%s_%s.png", filterName, formatExt); | |
System.out.println("Processing " + formatExt); | |
try (RasterImage image = (RasterImage) Image.load(inputFile)) | |
{ | |
doFilter.accept(image); | |
//If image is multipage save each page to png to demonstrate results | |
if (image instanceof IMultipageImage && ((IMultipageImage) image).getPageCount() > 1) | |
{ | |
IMultipageImage multiPage = (IMultipageImage) image; | |
final int pageCount = multiPage.getPageCount(); | |
final Image[] pages = multiPage.getPages(); | |
for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) | |
{ | |
String fileName = String.format("%s_page%d_%s.png", filterName, pageIndex, formatExt); | |
pages[pageIndex].save(fileName, new PngOptions()); | |
} | |
} | |
else | |
{ | |
image.save(outputFile, new PngOptions()); | |
} | |
} | |
//Remove rasterized vector image | |
if (isVectorFormat) | |
{ | |
new File(inputFile).delete(); | |
} | |
} | |
); | |
} | |
private static String rasterizeVectorImage(String formatExt, String inputFile) | |
{ | |
String outputFile = templatesFolder + "rasterized."+ formatExt + ".png"; | |
try (Image image = Image.load(inputFile)) | |
{ | |
image.save(outputFile, new PngOptions()); | |
} | |
return outputFile; | |
} |
About Aspose.Imaging for Java API
Aspose.Imaging API is an image processing solution to create, modify, draw or convert images (photos) within applications. It offers: cross-platform Image processing, including but not limited to conversions between various image formats (including uniform multi-page or multi-frame image processing), modifications such as drawing, working with graphic primitives, transformations (resize, crop, flip&rotate, binarization, grayscale, adjust), advanced image manipulation features (filtering, dithering, masking, deskewing), and memory optimization strategies. It’s a standalone library and does not depend on any software for image operations. One can easily add high-performance image conversion features with native APIs within projects. These are 100% private on-premise APIs and images are processed at your servers.Adjust EPS via Online App
Adjust EPS documents by visiting our Live Demos website The live demo has the following benefits
EPS What is EPS File Format
FIles with EPS extension essentially describe an Encapsulated PostScript language program that describes the appearance of a single page. The name "Encapsulated" because it can be included or encapsulated in another PostScript language page description. This script based file format may contain any combination of text, graphics and images. EPS files may include a bitmap preview image encapsulated inside for display by applications that can open such files. EPS files can be converted to standard image formats such as JPG, PNG, TIFF and PDF using different applications e.g. Adobe Illustrator, Photoshop and PaintShop Pro. Because of a security vulnerability in EPS files, Office 2016, Office 2013, Office 2010, and Office 365 have turned off the ability to insert EPS files into Office documents.
Read MoreOther Supported Adjust Formats
Using Java, you can easily Adjust different formats including: