본문 바로가기

Development/Java

PSD 포토샵 파일 Parser

728x90

http://blog.alternativaplatform.com/en/2007/07/09/parser-psd-formata/


PSDParser parser = new PSDParser(new FileInputStream("image.psd")); 
PSDLayerAndMask layerAndMask = parser.getLayerAndMask();    
 
List layers = layerAndMask.getLayers(); 
List images = layerAndMask.getImageLayers(); 
int i = 0; 
for (PSDLayerStructure layer : layers) { 
    PSDLayerPixelData pixelData = images.get(i); 
    BufferedImage image = pixelData.getImage(); 
    if (image != null) 
	ImageIO.write(image, "png", new File(layer.getName() + ".png")); 
	    i++; 
}

반응형