We are developing a desktop application using Java Swing that requires to show width and height of the 开发者_如何学JAVAselected .psd file. Also it needs to show the preview of the .psd file. Is it possible to do it in Java? If so how this can be done? Any help is appreciated greatly.
The java-psd-library does what you need.
try {
FileInputStream stream = new FileInputStream("image.psd");
PsdImage psdFile = new PsdImage(stream);
System.out.println("Image width: " + psdFile.getWidth());
System.out.println("Image height: " + psdFile.getHeight());
PsdView view = new PsdView();
view.setPsdFile(psdFile);
getContentPane().add(view);
} catch (IOException e) {
System.err.println("Error reading image file image.psd: " + e);
}
Try PSDReader ;)
精彩评论