Ferraz Outstanding Contributor.
Outstanding Contributor.
266 views

How convert base64 to a jpg file

Jump to solution

Hello,

I need to convert a base64 string to a jpg file. 

I'm using wpf in Visual Cobol.

Thanks

Alberto Ferraz

0 Likes
1 Solution

Accepted Solutions
Ferraz Outstanding Contributor.
Outstanding Contributor.

Re: How convert base64 to a jpg file

Jump to solution

Hi Ted,

Thank you for the tip, it works well.

I can convert the Base64 image and save it in jpg.

Best regards

Alberto Ferraz

 

 

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: How convert base64 to a jpg file

Jump to solution

If you are using .NET framework then it should be straight forward:

method-id Base64ToJpg (targetJpgPath as string, base64string as string).
declare imageBytes = type Convert::FromBase64String(base64string)
invoke type File::WriteAllBytes(targetJpgPath, imageBytes)
end method.

Assuming your base64 string is representing a JPEG blob. If it is another image format such as .png or .bmp then you will need to convert it first (you can do this using the Bitmap class in System.Drawing).

0 Likes
Ferraz Outstanding Contributor.
Outstanding Contributor.

Re: How convert base64 to a jpg file

Jump to solution

Hi Ted,

Thank you for the tip, it works well.

I can convert the Base64 image and save it in jpg.

Best regards

Alberto Ferraz

 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.