Adobe Photoshop (psd) support

Hi,

I’m using the latest version 3.5 and it does not seem to support Layered Photoshop files.

The code is very basic:


PsdImage psdImage = new PsdImage(inputStream);;
System.out.println(psdImage.getLayers());


The result is just one layer but the image has about 6.

Hi Nicholas,

Thank you for your inquiry.

The code should work fine. Please forward the sample PSD file that you are using at your end. This will help us recreate the issue.

Hi There,


Here’s the sample file I’m using:


Thank you
Hi Nicholas,

Thank you for providing sample PSD file.

We have tested the scenario at our end. Initial investigation shows that the issue persists. The issue has been logged into our system with ID IMAGING-35385. Our product team will look into it. We will update you via this forum thread.

Thank you Ikram. Appreciate the turn-around time:)
Nick

Hi Nicholas,

Thank you for your comments. We will update you via this forum thread as soon as ticket IMAGING-35385 is resolved.

Hi Ikram,

Did you get a chance to fix this bug? It’s been almost half year and our client is getting very impatient as his clients need to conclude this investigation.


Thank you,
Nick

Hi Nicholas,

Thank you for writing us back.

We have requested our product team to provide feedback on this issue. we will update you as soon as there is any update available.

We are very sorry for the inconvenience.

Hi Nicholas,

Thank you for your patience. The issue has been fixed. Please download the latest version Aspose.Imaging for Java version 16.10 and try it at your end. Feel free to reach us in case of any query or comments.

The issues you have found earlier (filed as IMAGINGJAVA-128) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Ikram,



I tried with the latest version (com.aspose:aspose-cad:1.1.0:jdk16) and and I got an exception when calling getLayers:



class com.aspose.imaging.coreexceptions.ImageLoadException: Cannot open an image. The image file format may be not supported at the moment.
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.e(Unknown Source)
com.aspose.imaging.internal.dT.aw.(Unknown Source)
com.aspose.imaging.fileformats.psd.PsdImage.(Unknown Source)
com.aspose.imaging.fileformats.psd.PsdImage.(Unknown Source)
com.aspose.imaging.fileformats.psd.PsdImage.(Unknown Source)
com.nuix.data.file.image.psd.PhotoshopDrawingData$1.compute(PhotoshopDrawingData.java:59)
com.nuix.data.file.image.psd.PhotoshopDrawingData$1.compute(PhotoshopDrawingData.java:52)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
com.nuix.common.concurrent.ExceptionLazyValue.get(ExceptionLazyValue.java:55)
com.nuix.data.file.image.psd.PhotoshopDrawingData.extractImageProperties(PhotoshopDrawingData.java:94)
com.nuix.data.file.image.AbstractImageData.populatePropertyMap(AbstractImageData.java:50)
com.nuix.data.AbstractData$2.compute(AbstractData.java:111)
com.nuix.data.AbstractData$2.compute(AbstractData.java:104)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
com.nuix.common.concurrent.ExceptionLazyValue.get(ExceptionLazyValue.java:55)
com.nuix.data.AbstractData.getPropertyMap(AbstractData.java:325)
com.nuix.data.file.image.psd.TestPhotoshopDrawingDataFactory.testLayered(TestPhotoshopDrawingDataFactory.java:65)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
com.nuix.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
com.nuix.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
com.nuix.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
com.nuix.common.test.rules.BaseTestRule$1.evaluate(BaseTestRule.java:45)
org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
com.nuix.common.test.rules.Timeout$CustomFailOnTimeout$StatementRunner.run(Timeout.java:137)
java.lang.Thread.run(Thread.java:745)


Could you retest and fix please.
Thank you,
Nicholas
Hi Nicholas,

Thank you for your inquiry.

This is to update you that you are using wrong API. Aspose.CAD API can be used to convert AutoCAD DWG and DXF files to PDF and raster images. Whereas Aspose.Imaging API can be used to work with Adobe Photoshop files.

Please download the latest version Aspose.Imaging for Java version 16.10 and try it at your end. Feel free to reach us in case of any query or comments.

Furthermore sample code has been given below for your reference.

CODE:

String sourceFileName = "Layered_PSD_file_bug.psd";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(sourceFileName);
try
{
com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image;
com.aspose.imaging.fileformats.psd.layers.Layer[] allLayers = psdImage.getLayers();
System.out.println("Layers count: " + allLayers.length); // must be 3
// Save layer number 2 to bmp
allLayers[1].save("out.bmp", new BmpOptions(), allLayers[1].getBounds());
}
finally
{
image.dispose();
}

Hi Ikram,


Sorry for the typo, moving to the new imaging forced me to also add the new cad library as that was removed from imaging but I was using the imaging library as you could see from the stack trace.

Cheers

I tested your code and it works when using he Image.load from the file. It does not work when loading from the constructor as in my code sample.

Hi Nicholas,

Thank you for writing us back.

We are able to observe the issue. The information has been forwarded to our product team. They will further look into it and provide feedback. We will update you about the progress via this forum thread.

Here is more detail:

String layeredFile = “C:/work/alternatetrunk/product/test-data/images/layered.psd”;

System.out.println(“Try opening the stream from file:”);
try (InputStream inputStream = Files.newInputStream(Paths.get(layeredFile), StandardOpenOption.READ))
{
PsdImage psdImage = new PsdImage(inputStream);
System.out.println(“count of layers when opening the stream from file:” + psdImage.getLayers().length);
}
catch (Exception e)
{
e.printStackTrace();
}
try (PsdImage psdImage = new PsdImage(layeredFile))
{
System.out.println(“count of layers when opening with Constructor from file:” + psdImage.getLayers().length);
}
catch (Exception e)
{
e.printStackTrace();
}
///////
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(layeredFile);
try
{
com.aspose.imaging.fileformats.psd.PsdImage psdImage = (com.aspose.imaging.fileformats.psd.PsdImage) image;
com.aspose.imaging.fileformats.psd.layers.Layer[] allLayers = psdImage.getLayers();
System.out.println("Aspose sample Layers count: " + allLayers.length); // must be 3
}
finally
{
image.dispose();
}




Console output is:
Try opening the stream from file:
count of layers when opening the stream from file:0
count of layers when opening with Constructor from file:0
Aspose sample Layers count: 3


So it seems that opening in Constructor fails both with filePath and with input Stream.

Also something weird I discovered is that the Image.load(layeredFile); that normally works, does not work in debug if you do step by step. It just hangs. It works in non-debug and also in debug if you don’t do a “Step Over”. I’m using Idea. Strange but not a showstopper.
Hi Nicholas,

Thank you for the detailed information. The information has been forwarded to our product team. They will consider it while investigating the issue.

Hi Nicholas,

This is to update you that it is correct, kindly look at the descriptions of constructors. It takes in a stream (stream to load pixel and palette data from and initialize with) object to instantiate a new object of PsdImage class. Constructor does not load any existing image (as it does in case of Image.Load method). It only creates new PsdImage without layers and copies into it the pixels from the image which is stored in stream.

Hope the above information helps. Feel free to contact us in case of any query or comments.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.