Foren
Convert image to Base64
Jitendra Rajput, geändert vor 12 Jahren.
Convert image to Base64
Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
Is that any Liferay class available to convert image into Base64 data format ?
MICHAIL MOUDATSOS, geändert vor 12 Jahren.
RE: Convert image to Base64
Regular Member Beiträge: 110 Beitrittsdatum: 04.10.11 Neueste Beiträge
If you can access the image from code you can do it easily yourself. Use ImageIO class (ImageIO.read()) to convert the image to a byte array (using the BufferedImage produced and ByteArrayOutputStream along with ImageIO.write() ). Then convert the byte array to a base64-encoded array using org.apache.commons.codec.binary.Base64.encodeBase64()
Liferay also has a Base64 utility, which you can use: com.liferay.portal.kernel.util.Base64
hope I helped...
Liferay also has a Base64 utility, which you can use: com.liferay.portal.kernel.util.Base64
hope I helped...
Jitendra Rajput, geändert vor 12 Jahren.
RE: Convert image to Base64
Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
thanks..will try as you suggested..!!
Jitendra Rajput, geändert vor 12 Jahren.
RE: Convert image to Base64
Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
Here is the sample code..
FileInputStream fileInputStream = new FileInputStream(filePath);
String base64Format = new String(Base64.encodeBase64(IOUtils.toByteArray(fileInputStream)));
Abigail Klinton, geändert vor 10 Jahren.
RE: Convert image to Base64
New Member Beiträge: 2 Beitrittsdatum: 25.09.13 Neueste Beiträge
HI there
I am not the user of Liferay for now.Because i am new here.But i'd like to have a try.I usually convert the image using this image converting program before.But it can not convert image into Base64 data format .So if liferay can do that,i'd like to have a try.
I am not the user of Liferay for now.Because i am new here.But i'd like to have a try.I usually convert the image using this image converting program before.But it can not convert image into Base64 data format .So if liferay can do that,i'd like to have a try.