PHP/Javabridge PSD File Layers not found

I’m using the PHP/Javabridge to talk to the Aspose.Imaging API.
I try to open the inlcuded logo with:

$image = new Java(“com.aspose.imaging.fileformats.psd.PsdImage”,$filename);

This goes okay and I can see I’ve got the image loaded, for example when I try to get the width and height it returns the right data to me.
When I try to get the layers with:

$layers = $image->getLayers();

I don’t receive any errors, but when inspecting the layers objet it only shows this:

[class [Lcom.aspose.imaging.fileformats.psd.layers.Layer;: Constructors: Fields: Methods: public final void java.lang.Object.wait() throws java.lang.InterruptedException public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException public boolean java.lang.Object.equals(java.lang.Object) public java.lang.String java.lang.Object.toString() public native int java.lang.Object.hashCode() public final native java.lang.Class java.lang.Object.getClass() public final native void java.lang.Object.notify() public final native void java.lang.Object.notifyAll() Classes: ]

and I can’t seem to access any of the layers.
When trying

$layers[0]

it will give an array out of bound error, while the file does have layers.

Could someone help me, what am I doing wrong?

Hi Heyne,

I have observed your inquiry and suggest you to please try using following sample code on your end in order to access PSD layers.

//get last layer position
$MaxLayers = psdImage->getLayers()->length;

//iterate all layers
for ($pos = 0; $pos < $MaxLayers; $pos++)
{
$layer=psdImage->getLayers()[$pos];

}


Please share, if there is still an issue on your end.

Many Thanks,

Mudassir:
Hi Heyne,

I have observed your inquiry and suggest you to please try using following sample code on your end in order to access PSD layers.

//get last layer position
$MaxLayers = psdImage->getLayers()->length;

//iterate all layers
for ($pos = 0; $pos < $MaxLayers; $pos++)
{
$layer=psdImage->getLayers()[$pos];

}


Please share, if there is still an issue on your end.

Many Thanks,

This I tried for myself to but it returns this error:
Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: GetProperty failed: [[o:Layer;]]->length. Cause: java.lang.NoSuchFieldException: length (with args:). Candidates: [] VM: 1.8.0_121@http://java.oracle.com/" at: #-6 php.java.bridge.JavaBridge.checkF(JavaBridge.java:1274) #-5 php.java.bridge.JavaBridge.GetSetProp(JavaBridge.java:1254) #-4 php.java.bridge.Request.handleRequest(Request.java:403) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1 php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:60) #0 C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(5, '[Lcom.aspose.im...', 'T', true) #1 C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc(361): java_Arg->getResult(true) #2 C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc(367): java_Client->getWrappedResult(true) #3 C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc(549): java_Client->getResult() #4 C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc(1747): java_Client->getPrope in C:\TBG\Tomcat\webapps\X-PAL\java\Java.inc on line 195

Hi Heyne,

I have set up PHP Java bridge environment on my end and have tried working over your requirements for accessing layers array. It seems to be an issue with Aspose.Imaging and we need to investigate this on our end. An issue with ID IMAGINGJAVA-707 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

We are sorry for your inconvenience,

Hi Heyne,

I request you to please try using attached PHP Script to access the layers inside image. I hope the shared information will be helpful. Please share, if I may help you further in this regard.

Many Thanks,

Hello Mudassir,


The script seems to work. Thank you very much.

Hi Heyne,

It’s good to know things have worked on your end. Please share, if I may help you further in this regard.

Many Thanks,

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