W
W
weranda2014-08-18 16:44:50
Image processing
weranda, 2014-08-18 16:44:50

How to encode an image to base64 with minimal code?

Greetings.
There is an image in base64

data:image/gif;base64,R0lGODlhBwAKAMIEAICAgJmZmbOzs/f39////////////////yH5BAEKAAcALAAAAAAHAAoAAAMWSDPUGoE5AaIj1M4qMW+ZFDYD1ClnAgA7

It has a white background. I need to change it to the background color #f2f2f2. I change in Photoshop in various formats. I insert it into the online converter and instead of a short record, a very large record appears
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAKCAYAAAB4zEQNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo2QTk2MDk2NjI2REMxMUU0OTZEQ0QxODBFMjY3M0IyRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo2QTk2MDk2NzI2REMxMUU0OTZEQ0QxODBFMjY3M0IyRCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjZBOTYwOTY0MjZEQzExRTQ5NkRDRDE4MEUyNjczQjJEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjZBOTYwOTY1MjZEQzExRTQ5NkRDRDE4MEUyNjczQjJEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+XngJ/QAAAGhJREFUeNqEkMENwCAMAw2vrECGYzhmYA3WgBHILzRIRa1KW/8sOycrTlUhIopDRORwkeu9a0ppmhjjreDNMDNaa7DSSZmXhjXlnLWUghDCIqxwV/D40D92F8y1tq7W+ggW9u0JQ4ABAKO1TeAFEfGiAAAAAElFTkSuQmCC

Please tell me how to save, with what parameters to make the record short?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-08-18
@weranda

ran the image through tinypng, converted.
I hope you understand that it all depends on the size of the image itself? You can also remove meta tags.

D
Dmitry Guketlev, 2014-08-18
@Yavanosta

Can't you set the background without an image?

Z
zooks, 2014-08-18
@zooks

You need to compress correctly in Photoshop or another graphic editor. The converter has nothing to do with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question