AX 2012 R3: Convert Images (JPEG) to Base64

How to convert images to base 64

public str (RefRecId _refRecId, RefTableId _refTableId)

System.Drawing.Image image;
System.IO.MemoryStream memoryStream;
str filePath = ”;
Filename fileName = ”;
DocuRef docuRef;

select docuRef
where docuRef.RefRecId == _refRecId
&& docuRef.RefTableId == _refTableId;

if (docuRef)

// Get Images complete File Name
fileName = docuRef.completeFilename();

image = System.Drawing.Image::FromFile(@Filename);
memoryStream = new System.IO.MemoryStream();
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat::get_Jpeg());
filePath = System.Convert::ToBase64String(memoryStream.ToArray());

return filePath;

Screen Shot:




Assuming parameters _refRecId and _refTableId came from InventTable where the Product Images is set in Released Product under Product Image function. See image below:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s