Free Support Forum - aspose.com

Cannot open an image

Image.load () method can’t load “JPG”, “PNG” file format

Caused by: class com.aspose.psd.coreexceptions.ImageLoadException: Cannot open an image. The image file format may be not supported at the moment or cannot be opened in such way.

@1395759132

Can you please share the details of what you are trying to do along with a working sample code reproducing it.

This is the line of code. I want to load an image file, but it reports an error. Is it currently not supported to load image files using Image.load()?

Image load = Image.load(dataDir + “/img/2.png”);

Exception in thread “main” class com.aspose.psd.coreexceptions.ImageLoadException: Image loading failed. —> class com.aspose.psd.coreexceptions.ImageLoadException: Cannot open an image. The image file format may be not supported at the moment or cannot be opened in such way. If you try to add Layer, please Open File as a Stream and use AddLayer method instead. Check the documentation https://docs.aspose.com/psd/net/add-layer-to-psd/

@1395759132

Aspose.PSD supports loading PSD files. In order to work with image formats like PNG, JPEG etc, please use Aspose.Imaging API on your end.

What should I do if I draw a picture in a layer?

@1395759132

I sugest you to please visit the following link for your convenience.