-1

How to write a Base64-encoded image to file?

I encoded an image to a string using Base64.
First, I read the file, then convert it to a byte array and then apply Base64 encoding to convert the image to a string.

Now my problem is how to compress image to 5kb.
Like Whatsapp Image Compression in Android.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
priyanka
  • 9
  • 3
  • As far as i can guide you... whatsapp doesnt compresses the image data rather it scales down the images to appropriate scale and bitdepth for netwrok transmission. thats why the whatsapp shared pictures are poor in quality – CoderNeji Jun 13 '18 at 12:47

1 Answers1

0

If what you need is to store the image as "text" you can compress the Base64 string SO answer. On the other hand you can reduce resolution of the image by lowering its size. Not all the images can be compressed to 5kb without losing quality, but making proper resolution changes and compresing the image it can be achieved Another SO answer.

Luby Shandra
  • 161
  • 1
  • 4