mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-10-04 11:26:44 -04:00
#403 Support for uncommon PSD resource magic: MeSa, PHUT, AgHg and DCSR
This commit is contained in:
@@ -38,7 +38,7 @@ package com.twelvemonkeys.imageio.plugins.psd;
|
||||
* @see <a href="http://www.adobe.com/devnet-apps/photoshop/fileformatashtml">Adobe Photoshop File Formats Specification</a>
|
||||
* @see <a href="http://www.fileformat.info/format/psd/egff.htm">Adobe Photoshop File Format Summary<a>
|
||||
*/
|
||||
interface PSD {
|
||||
interface PSD extends com.twelvemonkeys.imageio.metadata.psd.PSD {
|
||||
/** PSD 2+ Native format (.PSD) identifier "8BPS" */
|
||||
int SIGNATURE_8BPS = ('8' << 24) + ('B' << 16) + ('P' << 8) + 'S';
|
||||
|
||||
@@ -49,9 +49,7 @@ interface PSD {
|
||||
int VERSION_PSD = 1;
|
||||
int VERSION_PSB = 2;
|
||||
|
||||
/** PSD Resource type identifier "8BIM" */
|
||||
int RESOURCE_TYPE = ('8' << 24) + ('B' << 16) + ('I' << 8) + 'M';
|
||||
int RESOURCE_TYPE_LONG = ('8' << 24) + ('B' << 16) + ('6' << 8) + '4';;
|
||||
int RESOURCE_TYPE_LONG = ('8' << 24) + ('B' << 16) + ('6' << 8) + '4';
|
||||
|
||||
// Blending modes
|
||||
/** Pass through blending mode "pass"*/
|
||||
|
@@ -31,8 +31,8 @@ package com.twelvemonkeys.imageio.plugins.psd;
|
||||
import com.twelvemonkeys.imageio.stream.SubImageInputStream;
|
||||
import com.twelvemonkeys.lang.StringUtil;
|
||||
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import javax.imageio.IIOException;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@@ -163,8 +163,16 @@ public class PSDImageResource {
|
||||
|
||||
public static PSDImageResource read(final ImageInputStream pInput) throws IOException {
|
||||
int type = pInput.readInt();
|
||||
if (type != PSD.RESOURCE_TYPE) {
|
||||
throw new IIOException(String.format("Wrong image resource type, expected '8BIM': '%s'", PSDUtil.intToStr(type)));
|
||||
switch (type) {
|
||||
case com.twelvemonkeys.imageio.metadata.psd.PSD.RESOURCE_TYPE_IMAGEREADY:
|
||||
case com.twelvemonkeys.imageio.metadata.psd.PSD.RESOURCE_TYPE_PHOTODELUXE:
|
||||
case com.twelvemonkeys.imageio.metadata.psd.PSD.RESOURCE_TYPE_LIGHTROOM:
|
||||
case com.twelvemonkeys.imageio.metadata.psd.PSD.RESOURCE_TYPE_DCSR:
|
||||
// TODO: Warning for these types!
|
||||
case com.twelvemonkeys.imageio.metadata.psd.PSD.RESOURCE_TYPE:
|
||||
break;
|
||||
default:
|
||||
throw new IIOException(String.format("Wrong image resource type, expected '8BIM': '%s'", PSDUtil.intToStr(type)));
|
||||
}
|
||||
|
||||
// TODO: Have PSDImageResources defer actual parsing? (Just store stream offsets)
|
||||
|
@@ -96,8 +96,9 @@ public class PSDImageReaderTest extends ImageReaderAbstractTest<PSDImageReader>
|
||||
new TestData(getClassLoaderResource("/psd/masks2.psd"), new Dimension(640, 1136)),
|
||||
// RGB, multiple alpha channels, no transparency
|
||||
new TestData(getClassLoaderResource("/psd/rgb-multichannel-no-transparency.psd"), new Dimension(100, 100)),
|
||||
new TestData(getClassLoaderResource("/psb/rgb-multichannel-no-transparency.psb"), new Dimension(100, 100))
|
||||
// TODO: Need uncompressed PSD
|
||||
new TestData(getClassLoaderResource("/psb/rgb-multichannel-no-transparency.psb"), new Dimension(100, 100)),
|
||||
// CMYK, uncompressed + contains some uncommon MeSa (instead of 8BIM) resource blocks
|
||||
new TestData(getClassLoaderResource("/psd/fruit-cmyk-MeSa-resource.psd"), new Dimension(400, 191))
|
||||
// TODO: Need more recent ZIP compressed PSD files from CS2/CS3+
|
||||
);
|
||||
}
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user