cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gopalakrishnan
Helper III
Helper III

Converting an image to base 64 format

Hi,

How can I convert an image to base64 encoded format?

1 ACCEPTED SOLUTION

Accepted Solutions

hI Gopalakrishnan,

It's the same and you just need to change outputs('Get_user_photo_(V2)')?['body'].$content as your Google drive image content outputs from Google Drive connector 'get file content using path'. Then apply to above <img src.. /> html.

Please refer to this video for more details:
https://www.youtube.com/watch?v=ROGkAhrwmY8 

Best Regards

Johnny

Best Regards,
Johnny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Johnnyg
Microsoft
Microsoft

Hello Gopalakrishnan,

I test following expression and it works normally from my end. For your reference:

<img src="data&colon;image/jpeg;base64,@{body('Get_user_photo_(V2)')?['$content']}" alt="My Image" />

Expression: outputs('Get_user_photo_(V2)')?['body'].$content (insert after ‘base64,’ in following formula)

Johnnyg_0-1615087163100.png

Johnnyg_1-1615087245525.png

Results

 

Johnnyg_0-1615087553052.png

Best Regards,
Johnny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Johnnyg ,

Thanks for the reply.

My image file is located in Google drive. So can you update the expression according to that?

hI Gopalakrishnan,

It's the same and you just need to change outputs('Get_user_photo_(V2)')?['body'].$content as your Google drive image content outputs from Google Drive connector 'get file content using path'. Then apply to above <img src.. /> html.

Please refer to this video for more details:
https://www.youtube.com/watch?v=ROGkAhrwmY8 

Best Regards

Johnny

Best Regards,
Johnny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @Johnnyg ,

Thanks for the reply and it worked.

I need to repeat the process for all images in a folder in my drive. How can I loop through all files in my drive folder? Can I convert a 'PDF'  to base64 using the same process?

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (86,655)