I assume your image path is /resources/image.png. Below code show you how to read image from spring class path
if you got error
javax.imageio.IIOException: Can’t read input file!
java.lang.IllegalArgumentException: URI is not hierarchical
You should be using
when the resource is bundled as a jar/war or any other single file package for that matter.
then just change your code from
ImageIO.read(*…) will only load these image types GIF, PNG, JPEG, BMP, and WBMP.
Any other image type(ICO,WEBP) will return BufferedImage is null without error. You can’t rename the extension of file but you must convert image data to available image types.