google-code-export / project6014

Automatically exported from code.google.com/p/project6014
0 stars 0 forks source link

UQM image recompression script #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Write a program that will analyse the images in a UQM package, and recompress 
to JPG where suitable.  The corresponding .ani files will need to be rewritten 
too, if any of their images have changed.

Criteria for recompression are:

  1. Large.
  2. No use of transparency.
  3. JPG size is significantly less than PNG size.

Original issue reported on code.google.com by ejrh00@gmail.com on 13 Dec 2011 at 9:32

GoogleCodeExporter commented 9 years ago
I wrote a prototype script last night and ran it over the packages.  From 
memory, overall compression was about 20%.  For example the 4x HD package went 
from ~280MB to ~220MB.  Slightly disappointing compared to my off-the-cuff 
estimate of 50%.

Some backgrounds have minor amounts of transparency (which probably does not 
affect the appearance), which I accounted for; anything with min(alpha) >= 216 
was considered opaque.  Mostly it's the vast amount of hi-res ship graphics 
that we can't touch.

I still need to thoroughly test the script's effects -- to ensure no visible 
changes in game appearance.

If we consider it worth it, we could look into JPEG transparency.  Somehow.  I 
don't think it's a priority.

Original comment by ejrh00@gmail.com on 14 Dec 2011 at 11:08

GoogleCodeExporter commented 9 years ago
Still, I think 60 MB space savings is fantastic! That's a 22% decrease!

Original comment by dczanik@gmail.com on 14 Dec 2011 at 11:46

GoogleCodeExporter commented 9 years ago
The resulting graphics seem to be correct, at least in the main game.

Earlier testing showed incorrect graphics in the SuperMelee main screen.  This 
doesn't seem to appear any more but more thorough testing won't hurt.

Compression stats:

  - base.uqm                       49,884,809 to  41,715,079 (16%)
  - P6014-0.2.0-prv-hires2x.uqm   134,271,179 to 110,522,569 (18%)
  - P6014-0.2.0-prv-hires4x.uqm   300,714,209 to 234,109,934 (22%)

Using 90% compression; 80% gives marginal gains on these.

Not as much as originally hoped for.  A lot of large, transparent images in nav 
and planets that I underestimated.

Next steps:
  - Further testing for graphical quality.
  - Decide whether to employ.

Optional steps:
  - Add a mode for processing directories as well as UQM files.
  - Try to make more images compressible.

Original comment by ejrh00@gmail.com on 1 Jan 2012 at 11:54

GoogleCodeExporter commented 9 years ago
Now processes directories as well as UQMs.

Used in the 0.2.1 demo release.  Seems to have worked.  Got the 4x package down 
from 225 to 186 MB which means it doesn't have to be split on Google any more 
(until we make it bigger again).

The trick is to unzip the result, then recompress it using (e.g.) 7z, since the 
Python zipfile module seems to have unreliable compatibility.

Original comment by ejrh00@gmail.com on 21 Jan 2012 at 9:21