In our ongoing series about reading and writing image files in Java we move our focus onto how we can read PSD images in Java.
What is PSD?
PSD (Photoshop Document) is a format used by the popular Adobe Photoshop. The software which has its own format is used by many people for graphic designing and image editing. It uses the extension ‘.psd’.
A PSD file contains multiple objects including images, shapes, text, filters and other objects often used in graphic designing/editing. This allows Photoshop users to save, transfer and make further changes to their work in the future.
There are not many libraries out there that can read PSD images. Our JDeli Image library can read and write a very wide range of image formats, including PSD.
How to read PSD images in Java?
Below you will find an example of how to read PSD files using Java through JDeli.
//Read Image (can also be OutputStream or byte array) File psdFile = new File("psdImage.psd"); BufferedImage image = JDeli.read(psdFile);
Or you can use the JDeli PsdDecoder directly:
PsdDecoder decoder = new PsdDecoder(); BufferedImage image = decoder.read(rawImageBytes);
Why use JDeli?
JDeli offers a range of advantages over ImageIO and alternatives, including:
- prevents heap related JVM crashes
- implements unsupported image formats
- reduce output file size
- improve read/write performance
- supports threading
- superior image scaling algorithms
This article is part of our series on reading and writing image files in Java.
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.