Thursday, April 13, 2023
HomeProgrammingTips on how to Get a Base64 Model of a File From...

Tips on how to Get a Base64 Model of a File From Command Line


Some time again I wrote an article on learn how to Convert Picture to Information URI with JavaScript. It is a neat trick builders can use for any variety of causes. As a substitute of abusing canvas, nonetheless, why not merely get the base64 information 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 information, pbcopy copies to clipboard
base64 -i brand.jpeg | pbcopy

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

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

Whereas base64 information and information URIs do look cryptic, they’re helpful to keep away from making requests to different information. I take advantage of them when creating displays or after I cannot depend on a good web connection.

  • How to Create a Twitter Card
  • 7 Essential JavaScript Functions

    I bear in mind the early days of JavaScript the place you wanted a easy operate for almost every little thing as a result of the browser distributors carried out options in another way, and never simply edge options, primary options, like addEventListener and attachEvent.  Occasions have modified however there are nonetheless a couple of capabilities every developer ought to…

  • QuickBoxes for Dojo

    Including to my psychological portfolio is vital to me. First got here MooTools, then jQuery, and now Dojo. I converse typically with Peter Higgins of Dojo fame and determined it was time to step into his world. I selected a easy however helpful plugin…

  • Parallax Sound Waves Animating on Scroll

    Scrolling animations are enjoyable. They’re enjoyable to create and enjoyable to make use of. If you’re bored with bootstrapping you would possibly discover taking part in with scrolling animations as a pleasant juicy refreshment in your dry front-end improvement profession. Let’s take a look learn how to create animating…


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments