开发者

how to show preview and calculate width and height of .psd file using Java

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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜