Thursday, June 24, 2010

ZIPslim v0.991

How about GZ? Kzip by default DOESN'T support this file type. Lately I got in touch with a lot of tar.gz files due to my adventure with fun_plug for ZyXEL. I thought: "too bad I can't optimize these".

Until today. I have 4 spare days, including this one. I did research how GNUzip header/footer is built since I know it uses the same compression method ZIP does. Basically Deflate filestream is the same and you can notice GZ files being ~100 bytes smaller. So I managed to recreate artifical GZ header [1F 8B 08 00 00 00 00 00 02 00]. First two bytes would be fixed GZ file ID, 3rd is compression method meaning Deflate [08], next one is Null because we don't want to put filename inside archive saving [filename length]+1 bytes (it's not actually good idea to save it w/o filename inside since I know few internet services, like not existing savefile, that modified filename) - I may add ini switch to turn this on or off later. Starting from byte 5 I decided to skip (cause I'm lazy) time/date conversion to GNUzip specs so there are 4 Nulls (meaning it's the same as archive creation date). At byte 9 I decided to always use 02 since it means that it was packed with maximum compression (the thing 7-zip and kzip do) and last one is fixed 00 to let decompressor know that header ends here. If you want you can open it through Xvi32 or other hex editor and change header byte 4 [1F 8B 08 ->00<-] to 08 and add at the end of header filename.extension (00) so it will look like this: 1F 8B 08 08 00 00 00 00 02 00 asciifilenamehere.extension 00.

Let's check the ZIP footer. There is a lot of crap GNUzip don't want to see. Basically only things GZ wants is: 4 bytes long CRC written from right to left [reverse order] in hex format, and 4 bytes long file size written similar way. So the script coppies this and deletes anything else.

In order to use this feature you will need to reinstall script by running '0reinstall ZIPslim.bat' or by downloading and installing Xvi32 and editing ZIPslim.ini: add xvi32EXE=locationtoyourxvi32.exe for example 'xvi32EXE=apps\XVI32.exe'. Conversion is done by modifing HEX data of file with Xvi32 script file.

So that's how ZIPslim v0.991 was made, changelog:
- Changed Install zipslim.bat to 0reinstall zipslim.bat for EZ reinstalling.
- Reverted animation to old Moving Slash one
- Xvi32 added to main package to convert ZIP to GZ.
- GNUzip (.gz) extension support [ALPHA!]
* no support for file date (same as archive)
* no support for file name inside archive (same as archive minus .gz)
* it just converts ZIP to GZ by modifing ZIP header/footer to meet GZ specification.
*** PLEASE RUN 0reinstall zipslim.bat!
- Update to PNGslim display
- Fix for processing next files when resuming when BestBlocks was larger
than 16!
- Fix to PNGslim display: when file was detected as grayscale script
didn't display "Filters" text.

You can download it at

No comments: