What is the best image format for Android?

hackhack

Active Member
Licensed User
Longtime User
I was reading agraham explain why jpeg is a "slow" format.

So I was wondering, is there a better picture format? Something which be processed faster? PNG/BMP/TIFF - something else?

Anybody know?
 

sanduro

Member
Licensed User
Longtime User
It depends for what you need it for.

BMP is very much just RAW data, conseque is the VERY BIG file. only possible usage would be for really small pictures e.g. button backgroung or some small animation. Your SD card will be full and dead if you use this for big images

TIFF is pretty much as BMP , uncompressed but also can be used also as an wrapper for JPEG inside him. Trouble is that TIFF implementation in various programs are different and when you use it creative way it will produce creative results on different devices ( NOT all of them wanted ) , even on PC you can expierience different results eg in Photoshop and GIMP.

JPEG was created to minimize file size of photographs so it uses compresion and it is your choice how much you compress it and to destroy the quality of the picture. It has one major drawback it doesnt support tranparency.

PNG is pretty much the same as JPG but it supports transparency.

I use PNG , because I use heavily transparency option in my UI design.

I will be thinking about BMP only for small pictures i need flying fast to load. e.g. maybe some generated images or so

Agraham explains and provides how to work with BIG images and dont load them entirely to memory. DO NOT even try it with other than JPG and PNG.

Bigggiest issue you have on android is the main thread, so if you are thinking to read files/pictures from SD card, not your application repository NEVER do it in main thread. SD card might be busy for another application on android.
If you don't load everything you need for main thread in 2 seconds, android will KILL your app with "APPLICATION NOT RESPONDING" message.

Correct solution is to load you images in other process, not a main thread, either do it your self or use asyncstreams or better HTTPutils2.

Hopefully it explains the basics.

San
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
PNG is pretty much the same as JPG but it supports transparency.

PNG has nothing in common with JPEG. It's a lossless compression format, and for this reason, the files are bigger but with a perfect quality. It is become a standard de facto on Internet and mobile platforms and replaces more and more the GIF and BMP formats (and IMHO I can't see a reason to continue to use something else than PNG for graphics). This format is not made for photographs because the pictures taken by cameras are huge (so the resulting size after compression really matters), they do not need the alpha channel (for transparency), and their EXIF data cannot be embedded.
Note that the PNG files are sometimes a bit bigger than they should depending on the settings of the algorithm of your drawing app. You can use utilities like "Free PNG Optimizer" to get a smaller size.

Bigggiest issue you have on android is the main thread, so if you are thinking to read files/pictures from SD card, not your application repository NEVER do it in main thread. SD card might be busy for another application on android.

Only true for very large images on old devices. And an ANR is triggered after 5 seconds, not 2. So, in most cases, loading an image in the main thread is not a problem, but I agree that's better to load big files in the background if you cannot put a few DoEvents in the process.
 
Last edited:
Upvote 0

sanduro

Member
Licensed User
Longtime User
Yes you are right but i didnt want to go to technical details too much, PNG is great for low color, flat images when ut can use its full potential of lossless For vivid photo you get better results with JPG compressionwise, As for purist android developers to use the PNG for UI graphics is the only viable solution, for photos i would still consider JPEG as better option.

So you wanna small file on rich photo use JPEG, wanna small file for your UI interface which doesnt look like rainbow parrot with great quality ? use png
png has transparency which is great for us developers, loseless is not 100 perent loselles though , it fiddles with gamma settings and those would have different implementations depends on realization.

Wanna good quality and you don care if image might look little dull? use 0 quality option , wanna see original ? use 9 in gimp for PMG. It has also lotsa options their implementation might not be supported on all platfoms, though PNG is most usefull universal format for us unless you work for National Geographic or PLAYBOY, lol
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
PNG is great for low color

Low color ? The PNG format can use a palette 24-bit RGB (in fact 32 with the additional alpha channel), exactly like the JPEG format, but also a full-color non-palette-based RGB.

For vivid photo you get better results with JPG compressionwise

??? If you convert a JPG file to a PNG file, you will get the same image, exactly the same. No difference at all, except the size on disk. Try to do the contrary and you will lose visual quality. You'll get an image less sharp, less detailed, with modified colors. Unless my eyes are completely blind, JPEG images are usually more dull than the original image because of the losses. Sorry, but your comments do not make sense to me and I think that you should read a Wikipedia article on the PNG format because most of what you said about it is just plain wrong.
 
Upvote 0

sanduro

Member
Licensed User
Longtime User
This is about practical thing not technical.

If you use PNG for rich color Photos you end up with big file it is loosless so you cant make file smaller anymore. with JPEG you can get much smaller file without any significant quality loss human eye can recognize. So for sharing photos on the web far most practical format.

If you use flat color graphic with lotsa line like drawings then you use PNG which is looseless.
It keeps your lines nice , so far best format for what we need for UI for android, plus big benefit alpha channel. Why is not used on the web? Because some browsers doesnt support Alpha channel.
Problem is also embeeded gamma correction which might be missinterpreted by application and then you can end up with no matching colors

So it is not about storing the format it is about interpretation of the stored information in PNG.

Read this : http://morris-photographics.com/photoshop/articles/png-gamma.html

and this https://hsivonen.fi/png-gamma/
 
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Why is not used on the web? Because some browsers doesnt support Alpha channel.

PNG is the most used format on the web after JPG. Source. And all current browsers to my knowledge support the alpha channel. Even my old Internet Explorer 7 on my desktop at work displays PNG files without issues. Problems arise in IE7 when you play with opacity in your CSS but there are workarounds and it's not related at all to the initial question of this thread.

Problem is also embeeded gamma correction which might be missinterpreted by application and then you can end up with no matching colors

Yes, that's right, but it concerns old web browsers and not Android.
 
Upvote 0

pauleffect

Member
Licensed User
Longtime User
someone got burned.
@Informatix , google png vs jpg. second hit. you'll get where this dude got his arguments.

@sanduro. If you show me one browser that dosen't support png trans and that isn't discontinued or used by more than 1% of the world's pop, you're the man.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
use photoshop to make yours png and jpg 10kb 15 kb
for velocity use jpg
for quality use png
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…