Find out how to Get a Base64 Model of a File From Command Line


Some time again I wrote an article on methods to Convert Picture to Knowledge URI with JavaScript. It is a neat trick builders can use for any variety of causes. As an alternative of abusing canvas, nonetheless, why not merely get the base64 knowledge from command line?

You need to use base64 and pbcopy to transform a file to base64 and replica it to the clipboard:

# base64 will get knowledge, pbcopy copies to clipboard
base64 -i emblem.jpeg | pbcopy

After you have the file knowledge copied in base64 format, the URL format to make use of the information is:

# knowledge:{mime-type};base64,{knowledge}
knowledge:picture/jpeg;base64,/9j/4AAQSkZJRgAB......

Whereas base64 knowledge and knowledge URIs do look cryptic, they’re helpful to keep away from making requests to different information. I exploit them when creating displays or after I cannot rely on an honest web connection.

  • How to Create a RetroPie on Raspberry Pi – Graphical Guide

    In the present day we get to play superb video games on our tremendous powered recreation consoles, PCs, VR headsets, and even cellular units.  Whereas I get pleasure from taking part in new video games as of late, I do lengthy for the retro gaming methods I had after I was a child: the unique Nintendo…

  • CSS Animations Between Media Queries

    CSS animations are proper up there with sliced bread. CSS animations are environment friendly as a result of they are often {hardware} accelerated, they require no JavaScript overhead, and they’re composed of little or no CSS code. Very often we add CSS transforms to parts through CSS throughout…

  • jQuery Random Link Color Animations

    Everyone knows that we are able to set a hyperlink’s :hover colour, however what if we need to add a bit extra dynamism and aptitude? jQuery permits you to not solely animate to a specified colour, but additionally permits you to animate to a random colour. The…

  • CSS Animations Between Media Queries

    CSS animations are proper up there with sliced bread. CSS animations are environment friendly as a result of they are often {hardware} accelerated, they require no JavaScript overhead, and they’re composed of little or no CSS code. Very often we add CSS transforms to parts through CSS throughout…


Leave a Reply

Your email address will not be published. Required fields are marked *