Using JIMI to load PSD and convert to thumbnails

10-11  Source: Network gathering  Views:2 

Advertisement
Okay, I've tested out using JIMI to load a psd image to a JimiCanvas, but I can't seem to work out how to load the PSD file into a standard Image object (or what equivalent I need to transform it).
If I try:
JimiCanvas jc = new JimiCanvas(imageFilePath);
Image tempImage = jc.getImage();
Graphics tempg = tempImage.getGraphics();
Frame tempFrame = new Frame();
tempFrame.setSize(tempImage.getWidth(tempFrame)/4,tempImage.getHeight(tempFrame)/4);
tempFrame.getGraphics().drawImage(tempImage,0,0,tempFrame.getWidth(),tempFrame.getHeight(),tempFrame);
tempFrame.setVisible(true);I get the error:
java.lang.IllegalAccessError: getGraphics() only valid for images created with createImage(w, h)
     at sun.awt.windows.WImage.getGraphics(WImage.java:29)
     at org.ikeda.iris.photoshop.PhotoshopReader.<init>(PhotoshopReader.java:64)
     at org.ikeda.iris.photoshop.PhotoshopReader.main(PhotoshopReader.java:77)I've also been trying to work out how to use the PSDDecoder/Factory but I get so far:
PSDDecoderFactory psdff = new PSDDecoderFactory();
JimiDecoder jd = psdff.createDecoder();
JimiImageFactory jif = null;
jd.initDecoding(jif,fis);
java.awt.image.RenderedImage ri = null;and can't work out where to go from here.
My main task is to read in PSD images and create thumbnails.
Am I on the right track?
Are there any tutorials or docs that explain how to use it?
Cheers,
Anthony
I've sorted this problem out by just using a JimiCanvas:
JimiCanvas jc = new JimiCanvas(imagePath);
Image tempImage = jc.getimage();
tempImage = tempImage.getScaledInstancew(width, height, Image.SCALE_SMOOTH);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Jimi.putImage(JPG_MIME,tempImage,baos);
//save fileIt seems Jimi can load the psd file and do the conversion.
There is still the question of getting meta data from the image.
javax.imageio.metadata.* has some classes (it seems) to read metadata, however is this the same as the metadata a psd file may have assigned to if it's set up inside Photoshop? (adding comments, notes etc).
Cheers,
Anthony
Related articles