📜 ⬆️ ⬇️

Image to URI, easy way to convert

Greetings to all.
I read Habr for a long time, and somehow I never mentioned whether there is any easy way to convert images into data: URI.
Yes, of course there are online services for converting, but when mass conversion is required, it’s not very convenient to work in them.

Therefore, I began to search and found .

But since initially, this utility (I have only this, the language is turning) is a bit inconvenient.
I took up the finishing of this utility.

That's what happened
First, watch the video, it will immediately become clear.
')

HD link to YouTube

And now a little more.

There is such an archive.
image

In him…
image

Well, completely here ...
image

We want to translate this image in data: URI
image

To do this, we throw it into the image2css folder and run the package z_1.cmd
At the output we get the finished file with data: URI

image

Note:
1. You can do the conversion in bulk for this archive is a file z_.cmd
2. There is Notepad2 in this archive, it is needed in order to show us the code, since the native Notepad annoys me terribly.
3. You can drop a file with any name into the folder, it will automatically be renamed to favicon.png.
4. If you want to encode a GIF image then, for this you only need to change the extension to gif in the file z_1.cmd .
5. Since I am a forgetful guy, I made auto backup of all the converted files.
Those. folders
aspng - keeps all the converted png pictures
asuri - stores in itself all converted URI text files.

And also, do not forget the utility needs installed Java.

Well, the very image2css.7z utility on Yandex Disk.

I hope my script will help you, because I did it for myself, well, I think it will not be nice not to share with the people.

UPD 1.
So that the writers' works are not in vain, because the article is already in the index and will help the pioneers and just webmasters.

Method 1
Conversion by PHP from zapimir
<form method="post" action="#" enctype="multipart/form-data"><input type="file" name="file"/> <input type="submit" value="  URI"/></form> <?php if(isset($_FILES['file'])){ echo "<textarea rows='1' cols='1' style='margin:10px;width:100%;height:800px;border:2px solid #333'>url(data:{$_FILES['file']['type']};base64, " . base64_encode(file_get_contents($_FILES['file']['tmp_name'])) . ')</textarea>'; } ?> 


Method 2
Linux conversion by Stdit
 $ find . -name "*.png" -exec echo {} " -> " \; -exec base64 {} \; 


Method 3
Conversion of windows by silvansky
Data URI Generator
The program builds its menu item when you press RMB on the css file.
And from the original css (in which links to the pictures) it generates into a separate css (data uri)

Source: https://habr.com/ru/post/142637/


All Articles