Some time again I wrote an article on how one can 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 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 brand.jpeg | pbcopy
After getting the file knowledge copied in base64 format, the URL format to make use of the info 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 recordsdata. I take advantage of them when creating displays or once I cannot rely on a good web connection.
fetch API
One of many worst stored secrets and techniques about AJAX on the internet is that the underlying API for it,
XMLHttpRequest
, wasn’t actually made for what we have been utilizing it for. We have achieved properly to create elegant APIs round XHR however we all know we will do higher. Our effort to…9 Thoughts-Blowing WebGL Demos
As a lot as builders now detest Flash, we’re nonetheless taking part in a little bit of catch as much as natively duplicate the animation capabilities that Adobe’s outdated know-how offered us. After all now we have canvas, an superior know-how, one which I highlighted 9 mind-blowing demos. One other know-how accessible…
Introducing MooTools ScrollSpy
I have been excited to launch this plugin for a very long time. MooTools ScrollSpy is a singular however easy MooTools plugin that listens to web page scrolling and fires occasions primarily based on the place the person has scrolled to within the web page. Now you possibly can fireplace particular…
CSS Triangles
I used to be lately redesigning my web site and wished to create tooltips. Making that was simple however I additionally wished my tooltips to function the a triangular pointer. I am a catastrophe in terms of pictures and the prospect of needing to make a picture for…