[SCRIPT][Windows7-64]ROM and APK Compressor v3
So here is the latest version of Windows batch script which will process apk, zip and jar files. I used it to successfully create 3 ROMs based on Froyo, GB and ICS.
Changes to v3 - files and paths with spaces should work fine. 64 to 16 colors disabled.
Changes to v2 - 64 color images color quantized to 16 (can be disabled in code). Theme copied files are resized to match destination png size, which helps with hdpi folder going to xhdpi. Mulithreaded pngcrush - splits png filelist into number of CPUs.
It processes PNG, JPG, OGG and MP3 files with lossy compression, to reduce color depth to 256 or apply mono bitrate 64kbps sample rate 22kHz to sounds.
It runs without human interaction. It is not very fast, and cannot be run concurrently as several threads due to temporary files being used as variables, and imageq.exe (cq.exe) logic for dithering PNGs and unable to run as several instances (it's GUI Windows app).
Source themed application resources are copied into target directory to preserve theming with new code.
Resulted resources then repacked using Kzip for deflated resources and 7-zip for stored resources. Input file structure kept, so what came as stored, will be stored, so framework apks and jars are safely processed.
Typical workflow to process ROM zip-file would be to put apks and jars into ./place-apk-here-to-batch-optimize . And any themed apks into ./place-apk-src.
Then get results from %TEMP%\optimizedapk and put them back into ROM zip.
Next put ROM zip into ./place-apk-here-to-batch-optimize and run one more time to process media files in ROM itself, and have better KZip packing.
Testing apks one-by-one is recommended in the beginning, since results cannot be guaranteed.
User (non system) apks also can be compacted to further improve system performance and reduce file sizes. Updating user apps from Market (G-Play) will then become a problem, because apks signed using test certificate. You have to uninstall/install from Market to solve it and you also will loose your pics/snds compression.
ffmpeg.exe/ffprobe.exe are only 64-bit apps here. You can try to replace them by 32-bit, but my attempts got always buggy ffmpeg.exe, so ...
To get slightly faster processing the whole folder can be copied to noncompressed RAMDisk (I use free IMDisk) and TEMP folder to be set to RAMDisk (R:\Temp for example).
rem *** credits - ApkManager 4.9, apkopt, ImageMagick, 7-zip, signapk, zipalign, PNGScript
REM *** Usage: MainScript.bat sign|sys repack|process
REM *** Incoming files are in "./place-apk-here-to-batch-optimize" DIR
REM *** Source files with themed pictures/sounds are in "./place-apk-src" DIR
REM *** Incoming files cannot have spaces IN the name
REM *** Result is in "%TEMP%\optimizedapk" dir
REM *** Please check JAVA_HOME and TEMP variables!!! ***
REM *** "process" option performs lossy compression of PNG, JPG, OGG, MP3 and WAV files
REM *** result of "process" is up to 50% smaller apks, faster loading times, overall faster operation
REM *** Example to process(PNG) system apks: MainScript.bat sys process
REM *** Example to process(PNG) user apks: MainScript.bat sign process
REM *** Example to repack (Kzip maximum) system apks: MainScript.bat sys repack
Make your variables and Java path shorter and have no spaces (it helps with debugging):
Under "place-apk-here-to-batch-optimize" should be files with extensions .apk, .zip and .jar
If there are no files with those extensions - no error is produced.
To log errors - enable echo in zipb.cmd and run something like:
MainScript.bat sys process >out.txt 2>err.txt
Check out.txt and err.txt for messages.
Previous version links