Results 1 to 3 of 3

Thread: TGA compressor

  1. #1

    Default TGA compressor

    Download the tool.

    Java source included. Anyone can use it however you like, except copyrighting it.

    I forget when, but a couple years ago I created a tool for EB2 that would compress those TGA images that would get sufficiently reduced space by compressing, to reduce the size of the release. I dusted it off recently and thought I'd put it out there for anyone else to use for their mods.

    You need to have Java installed, and you need to change runConversion.bat to point to your mod.

    What it does is fairly straightforward:
    1 Run through the full mod structure
    2 Investigate files ending with .tga
    2a Skip already compressed files
    2b Write a compressed file to replace the fullsize one

    Example of its logging, to demonstrate what it can do:

    Quote Originally Posted by tga compressor
    (...)
    Listing ../../../mods/EBII/data/ui/cul_1
    Listing ../../../mods/EBII/data/ui/cul_1/buildings
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_battle_L1_constructed.tga... Compressing... Done, now 218167 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_battle_L2_constructed.tga... Compressing... Done, now 219112 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_battle_L3_constructed.tga... Compressing... Done, now 219215 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_battle_L4_constructed.tga... Compressing... Done, now 218582 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_battle_L5_constructed.tga... Compressing... Done, now 217493 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_farming_L1_constructed.tga... Compressing... Done, now 218095 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_farming_L2_constructed.tga... Compressing... Done, now 219155 bytes.
    Reading 220220 bytes from ../../../mods/EBII/data/ui/cul_1/buildings/#cul_1_temple_of_farming_L3_constructed.tga... Compressing... Done, now 219209 bytes.
    (...)
    Listing ../../../mods/EBII/data/ui/cul_2/buildings/construction
    Reading 13100 bytes from ../../../mods/EBII/data/ui/cul_2/buildings/construction/#cul_2_farms_six.tga... Compressing... Done, now 8902 bytes.
    Reading 13100 bytes from ../../../mods/EBII/data/ui/cul_2/buildings/construction/#cul_2_roads_garrison_two.tga... Compressing... Done, now 9738 bytes.
    Listing ../../../mods/EBII/data/ui/cul_2/cities
    Listing ../../../mods/EBII/data/ui/cul_2/eventpics
    Reading 229804 bytes from ../../../mods/EBII/data/ui/cul_2/eventpics/assassin_failed.tga... Compressing... Done, now 227078 bytes.
    Reading 140204 bytes from ../../../mods/EBII/data/ui/cul_2/eventpics/battle_generaldeathfriendly.tga... Compressing... Done, now 140543 bytes.
    Reading 169964 bytes from ../../../mods/EBII/data/ui/cul_2/eventpics/character_dies_natural.tga... Compressing... Done, now 170381 bytes.

    (...)
    Listing ../../../mods/EBII/data/world/maps/base
    Reading 1834755 bytes from ../../../mods/EBII/data/world/maps/base/map_fog.tga... Compressing... Done, now 19130 bytes.
    Reading 457488 bytes from ../../../mods/EBII/data/world/maps/base/map_regions.tga... Compressing... Done, now 32898 bytes.
    Reading 1829898 bytes from ../../../mods/EBII/data/world/maps/base/map_roughness.tga... Compressing... Done, now 19082 bytes.
    Reading 457488 bytes from ../../../mods/EBII/data/world/maps/base/map_trade_routes.tga... Compressing... Done, now 4786 bytes.
    Reading 196652 bytes from ../../../mods/EBII/data/world/maps/base/water_surface.tga... Compressing... Done, now 195386 bytes.


    As you can see, individual files can gain a reduction in size of up to 99% in the best of cases, but may even turn out a few bytes LARGER than uncompressed in the worst of them. This is because this version is modified to not do any estimating of gain before compressing. This saves literally hours of time when there are many images that would not benefit much, as they need to be fully read and inspected for the estimation.


    The size reduction gets realized when neighbouring pixels have the same colour ("run length encoding", meaning instead of RED RED RED RED RED it writes 5RED). Many images have a fair bit of "transparent" in them which is typically clustered together and gets excellent compression, and those map images you can see marked blue similarly have a ton of neighbouring pixels with the same colour. When hardly any pixels are the same as their neighbours, the control markers for the compression adds to the file size with no or almost no gain, but thankfully they are only a few bytes dead weight.

    NB! Your images will get overwritten as part of this process. If there is a bug in the tool (not found as part of EB2's use), they will be essentially destroyed. You should definitely have a backup handy (either as a full copy of your files or checked into some kind of version control) if it fails on your images.

    Note that if you kill the process while it is currently compressing, that file will be corrupted! Killing the process while reading a file is okay.
    Last edited by bovi; February 09, 2021 at 01:19 PM.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  2. #2
    _Tartaros_'s Avatar "Harzschütze"
    Join Date
    Aug 2009
    Location
    kvet.lɪnˌbuʁk
    Posts
    4,492

    Default Re: TGA compressor

    damn, let´s give it a go!!
    thank you for uploading and sharing

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,124
    Blog Entries
    35

    Default Re: TGA compressor

    Ah yes, I remember that discussion in in the EBII forum. Great tool if you don't use GIMP - it is set by default to save in compressed format.
    Will keep it handy when working with other mods.










Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •