[TOP TIP] Image to embed

It is common in web development to embed small images within CSS or HTML. Here is a quick PHP script to help you convert an image to the proper serialized embed data.

Save the following as img2embed and make it executable (chmod +x img2embed)

#!/usr/bin/env php

Execute the script and give it the filename of the image as a parameter:

$ img2embed linode_logo_white.png 
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHMAAAAtCAYAAA...

The script is pretty basic, it does not do any checking about the input file, so if you want you can add that functionality yourself.

Enjoy!

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct