Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

How to convert a bufferedImage to Dam Asset

Avatar

Level 3

Hi ,

I have an image object in the form of java.awt.image.BufferedImage .

 BufferedImage image = ImageIO.read(filepath);

I want  to create a Dam asset using this object.

Please sugget ways in which this can be done.

 

Thank you in advance

Harish

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Harish,

Did you look at the createAsset method of AssetManager? See http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/dam/api/AssetManager.html#createAsset(java...., java.io.InputStream, java.lang.String, boolean)

This accepts an InputStream. There's no need to parse the image file into a BufferedImage. If you had generated a BufferedImage through some other means (say, by generating one from scratch), you can use the ImageIO API to generate a byte array from the BufferedImage and then pipe that into an InputStream.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Hi Harish,

Did you look at the createAsset method of AssetManager? See http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/dam/api/AssetManager.html#createAsset(java...., java.io.InputStream, java.lang.String, boolean)

This accepts an InputStream. There's no need to parse the image file into a BufferedImage. If you had generated a BufferedImage through some other means (say, by generating one from scratch), you can use the ImageIO API to generate a byte array from the BufferedImage and then pipe that into an InputStream.