Search code examples
htmlimagebase64screenshot

How to display a base64 jpeg image correctly?


I've the following problem:

I want to display a screenshot of an other website (I used GoogleAPI to realize that), but something goes wrong.

I use Jquery to get the "screenshot-code" from the following site: https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=https://stackoverflow.com/questions&screenshot=true

Then I try this, but the image does not get displayed:

<img style="width: 300px; height: 300px;" src="data:image/jpeg;base64,_9j_4AAQSkZJR...............aKs3c__Z" />

Solution

  • It’s URL-safe base64; replace - with + and _ with / to convert it to normal base64 for use in a data URI.