我试图用JAVA从PSD文件中读取DPI。我使用的是ImageIO(包括TwelveMonkeys扩展)和/或Apache Commons Imaging。遗憾的是无法管理它(JPG,PNG和TIFF工作正常)
这是来自photoshop的文件信息:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>Adobe Photoshop CS6 (Macintosh)</xmp:CreatorTool>
<xmp:CreateDate>2017-05-18T10:47:41+02:00</xmp:CreateDate>
<xmp:MetadataDate>2017-05-18T11:17:54+02:00</xmp:MetadataDate>
<xmp:ModifyDate>2017-05-18T11:17:54+02:00</xmp:ModifyDate>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/vnd.adobe.photoshop</dc:format>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#">
<xmpMM:InstanceID>xmp.iid:96F5C1320B206811822AAF07DD778819</xmpMM:InstanceID>
<xmpMM:DocumentID>xmp.did:0180117407206811822AAF07DD778819</xmpMM:DocumentID>
<xmpMM:OriginalDocumentID>xmp.did:0180117407206811822AAF07DD778819</xmpMM:OriginalDocumentID>
<xmpMM:History>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<stEvt:action>created</stEvt:action>
<stEvt:instanceID>xmp.iid:0180117407206811822AAF07DD778819</stEvt:instanceID>
<stEvt:when>2017-05-18T10:47:41+02:00</stEvt:when>
<stEvt:softwareAgent>Adobe Photoshop CS6 (Macintosh)</stEvt:softwareAgent>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<stEvt:action>saved</stEvt:action>
<stEvt:instanceID>xmp.iid:0280117407206811822AAF07DD778819</stEvt:instanceID>
<stEvt:when>2017-05-18T10:48:03+02:00</stEvt:when>
<stEvt:softwareAgent>Adobe Photoshop CS6 (Macintosh)</stEvt:softwareAgent>
<stEvt:changed>/</stEvt:changed>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<stEvt:action>saved</stEvt:action>
<stEvt:instanceID>xmp.iid:96F5C1320B206811822AAF07DD778819</stEvt:instanceID>
<stEvt:when>2017-05-18T11:17:54+02:00</stEvt:when>
<stEvt:softwareAgent>Adobe Photoshop CS6 (Macintosh)</stEvt:softwareAgent>
<stEvt:changed>/</stEvt:changed>
</rdf:li>
</rdf:Seq>
</xmpMM:History>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:ColorMode>3</photoshop:ColorMode>
<photoshop:ICCProfile>sRGB IEC61966-2.1</photoshop:ICCProfile>
<photoshop:TextLayers>
<rdf:Bag>
<rdf:li rdf:parseType="Resource">
<photoshop:LayerName>OK PSD 2557x2200px 150dpi RGB</photoshop:LayerName>
<photoshop:LayerText>OK PSD 2557x2200px 150dpi RGB</photoshop:LayerText>
</rdf:li>
</rdf:Bag>
</photoshop:TextLayers>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:tiff="http://ns.adobe.com/tiff/1.0/">
<tiff:Orientation>1</tiff:Orientation>
<tiff:XResolution>1500000/10000</tiff:XResolution>
<tiff:YResolution>1500000/10000</tiff:YResolution>
<tiff:ResolutionUnit>2</tiff:ResolutionUnit>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:exif="http://ns.adobe.com/exif/1.0/">
<exif:ColorSpace>1</exif:ColorSpace>
<exif:PixelXDimension>2557</exif:PixelXDimension>
<exif:PixelYDimension>2200</exif:PixelYDimension>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
如果我能得到这个部分会很酷:
<tiff:XResolution>1500000/10000</tiff:XResolution>
<tiff:YResolution>1500000/10000</tiff:YResolution>
我正在读这样的维度:
final IIOMetadata metadata = reader.get().getImageMetadata(0);
final IIOMetadataNode standardTree = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
final IIOMetadataNode dimension = (IIOMetadataNode) standardTree.getElementsByTagName("Dimension").item(0);
THX