6

I was having image size problem with my iOS app, and I discovered this article while finding some image size optimization solution

After reading it, I realized I don't need to use only PNG or JPEG. Actually, I can use any image format which is not supported on iOS platform by default. Because if I can get actual pixels, converting it to UIImage via CGImage is just a simple work. I can use special bitmap format and special decoder. For an example, there's a technique called texture atlas which stores many images within a big bitmap, and it can save extra duplicated buckets.

So I'm asking about most smallest (when compressed) lossless image compression format and/or library. If you know some great format or library, I wish you to recommend it to me.

It would be nice if it's open-source, but I don't mind if it's proprietary closed-source, and paid solution. What I need is only awesome image compression, not source code. Of course, it must be usable on iOS platform, so it should offer decoder usable in C, C+ or Objective-C language. (I don't need encoder in these platform)

eonil
  • 83,476
  • 81
  • 317
  • 516
  • Any image compression algorithm is going to perform better on some images than on others. What kinds of images are you working with (photographs, line drawings, scanned text, etc.)? – Adam Mihalcin Mar 23 '12 at 01:51
  • What kind of image are you compressing? PNG is usually regarded as "good enough" for things like screenshots. And on iPhone, processing power might be a limitation. – Potatoswatter Mar 23 '12 at 01:51
  • @Adam My images mainly are UI stuffs. Usually graphics drawn by tools like Photoshop or Illustrator. Not photos. But usually it can have photography level of details. – eonil Mar 23 '12 at 01:56
  • @Potatoswatter Most of images I'm using are UI stuffs. And I don't care about encoding cost because I don't encode it on device, but decoding cost should be affordable. I mean, it doesn't need to be super-fast like soft-realtime, but shouldn't take minutes to use. For example, if it's a huge atlas takes minutes to load, loading part of image faster must be supported. – eonil Mar 23 '12 at 02:00
  • @Eonil: UI as in buttons? That doesn't really explain what they *look* like. A button can be a solid color, a photograph, or anything. An atlas, likewise, might have many photos or just solid-colored maps with lines here and there. – Potatoswatter Mar 23 '12 at 02:06
  • @Potatoswatter That's what I mean. It can be anything so I assume it photography because it usually has high details and less consistent. And I did many of content-aware optimization manually. If the button is stretched gradient, I use 1-pixel wide texture. – eonil Mar 23 '12 at 02:21
  • What kind of problem do you have? maybe you can use svg with this https://github.com/SVGKit/SVGKit – JIE WANG Dec 19 '21 at 07:14

2 Answers2

1

Different images have different compressions. With JPEG you sacrifice quality for smaller size and with PNG 24 you get alpha transparency. What you're probably more interested in is getting the smallest size image possible for the format you're using. There are 2 good command line tools for handling this. You kind of have to play around with different types, programs like photoshop make it really easy to see which is smallest. Once you've found your optimum format you can use a "smusher" to remove extraneous data that isn't needed by the image but often gets added by the editor. Below are 2 command line utilities I uses to make sure my images are as small s possible when building websites, but are also beneficial for any application.

optipng: http://optipng.sourceforge.net/ jpegoptim: https://github.com/glennr/jpegoptim#readme

both can be installed easily using homebrew: Link and I'd assume theres an option for macports as well.

There also C-based so either can be used in an iOS project.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Chris
  • 756
  • 4
  • 11
1

If you want to optimise JPEG, I'd go for http://jpegmini.com

If you want to step out of JPEG and PNG you could try Google's WebP (http://code.google.com/speed/webp/) but I have no idea if there are any iOS libraries for it and if they are whether they are any good.

Andy Davies
  • 5,794
  • 2
  • 26
  • 21