Results 1 to 4 of 4

Thread: kzip2gz a .zip (single file & deflate compression) to .gz converter

  1. #1
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    190
    Thanks
    8
    Thanked 62 Times in 33 Posts

    kzip2gz a .zip (single file & deflate compression) to .gz converter

    Hello,
    Ken Silverman's KZIP is a good (but slow) command line .zip archiver, it only handles Deflate compression.
    Since I was looking for a way to optimize .gz (Gzip) compressed files, I wrote a small tool that turns a single file .zip archive produced by KZIP into a .gz file without recompression.

    kzip2gz: converts the first deflated file found in a zip archive into a gzip file.
    Version 0.3a (25 Sep. 2012) by Frederic Kayser
    Usage: kzip2gz input_file.zip output_file.gz

    It's not bulletproof since it has not been tested against other ZIP archivers.

    Todo list:
    - check if the first file is effectively compressed with Deflate and not something else (stored, Deflate64, bzip2, LZMA...).

    Incidentally Huffmix 0.5 handles .gz files...
    Attached Files Attached Files
    Last edited by caveman; 6th November 2012 at 03:32. Reason: Huffmix crosslinking

  2. The Following 3 Users Say Thank You to caveman For This Useful Post:

    lorents17 (15th April 2015),Matt Mahoney (15th April 2015),Mr_KrzYch00 (26th April 2015)

  3. #2
    Member Jaff's Avatar
    Join Date
    Oct 2012
    Location
    Dracula's country
    Posts
    100
    Thanks
    112
    Thanked 20 Times in 16 Posts

    some sugestions

    A way to optimise compresion is after kzip job is to try those tools & options:
    Code:
    deflopt /a/b/d/r archive.zip
    advzip -z -4 archive.zip
    defluff <archive.zip >archive2.zip
    deflopt /a/b/d/r archive.zip
    deflopt /a/b/d/r archive2.zip
    That's ZIP pass optimisation. Usually the second archive is with few bytes smaller. Also it's good to know that you can apply defluff optimisation to archive in ZIP or GZ form. Now we can chose the smallest file from archive.zip & archive2.zip and go with the final step: kzip2gz I've noticed that kzip2gz dosen't keen the filename and timestamp of the file in archive (like Total Commander, gzip* and gziphack* (*optional))

    My sugestions are:
    - option to keep or not filename & timestamp
    - convert all files form a zip file (root of archive only / do not convert the files in subfolders to avoid duplicate filenames / or ignore duplicate filenames)
    - also make an utility to do the gz2zip conversion too

  4. #3
    Member caveman's Avatar
    Join Date
    Jul 2009
    Location
    Strasbourg, France
    Posts
    190
    Thanks
    8
    Thanked 62 Times in 33 Posts
    Thank you for your suggestions.
    Keeping the name is easy, the time-stamp is a bit more tricky, I may add this in the next version.

    I usually run loops of kzip -> kzip2gz -> deflopt -> defluff -> deflopt -> huffmix.
    Kzip is called in random mode (-rn option) and with different blocks (-n option between 1 and 1024).

    After a lot of time it produces:

    book1.gz
    298,518 bytes
    compared to:
    312,275 bytes gzip -9n
    299,455 bytes kzip alone after zip to gz conversion
    299,214 bytes zopfli
    299,069 bytes zopfli --splitlast
    298,701 bytes zopfli --i1000
    298,746 bytes zopfli --i1000 --splitlast

    Newer zopfli (build from source end of summer 2014)
    299,504 bytes zopfli
    299,054 bytes zopfli --splitlast
    298,695 bytes zopfli --i1000
    298,737 bytes zopfli --i1000 --splitlast

    enwik8.gz
    34,929,996 bytes
    compared to:
    36,445,241 bytes gzip -9n or .zip archive from Matt Mahoney after zip to gz conversion
    35,025,675 bytes kzip alone after zip to gz conversion
    34,995,515 bytes zopfli
    35,161,685 bytes zopfli --splitlast
    34,980,326 bytes zopfli --i1000
    35,148,080 bytes zopfli --i1000 --splitlast
    Attached Files Attached Files
    Last edited by caveman; 25th October 2014 at 18:50. Reason: Updated some figures and book1.gz file

  5. #4
    Member Mr_KrzYch00's Avatar
    Join Date
    Apr 2015
    Location
    Poland
    Posts
    65
    Thanks
    10
    Thanked 40 Times in 24 Posts
    Since I was using this tool to convert ZIP to GZ to optimize them later using huffmix. I made my own script to convert the file back from GZ to ZIP to be used with ZIPMIX. It was written in php on windows using php 5.3.

    Code may be a bit messy, I was mostly concerned about it working.

    It works on standard header GZip files that don't store filename. Doesn't process timestamps as well.

    You are, however, free to edit the file and extend its functionality.

    The script itself was converted from GZ to ZIP using gz2kzip.php...

    EDIT: v1.01 is out:
    - added support for GZ timestamps to be converted to ZIP file standard (use current time if no timestamp is detected),
    - added support for filename inside GZ archive,
    - better displaying of on-screen information:
    Code:
    e:\php>php gz2kzip.php gz2kzip.php.gz
    
    No Unix timestamp detected, will use current time:  . . 1 430 063 319
    No filename detected in GZ file, will use:  . . . . . . gz2kzip.php
    MS-DOS Format Date (converted): . . . . . . . . . . . . 18 074
    MS-DOS Format Time (converted): . . . . . . . . . . . . 36 371
    Original Size:  . . . . . . . . . . . . . . . . . . . . 7 299 bytes
    Packed Size (Compressed): . . . . . . . . . . . . . . . 2 005 bytes
    CRC32:  . . . . . . . . . . . . . . . . . . . . . . . . DA7C5DBE
    Written bytes:  . . . . . . . . . . . . . . . . . . . . 2 125 bytes
    
    
    Successfully converted GZ to ZIP file (Deflate stream coppied) . . .
    Attached Files Attached Files
    Last edited by Mr_KrzYch00; 26th April 2015 at 18:55.

  6. The Following 2 Users Say Thank You to Mr_KrzYch00 For This Useful Post:

    Jaff (15th April 2015),lorents17 (28th April 2015)

Similar Threads

  1. CDDA Compression via FreeArc & Ext. Encoder
    By MiY4Gi in forum Data Compression
    Replies: 1
    Last Post: 26th June 2012, 09:34
  2. can zip directory entries share file entries?
    By willvarfar in forum Data Compression
    Replies: 1
    Last Post: 23rd February 2011, 15:46
  3. Idea: Combine Compression & Encryption
    By dirks in forum Data Compression
    Replies: 16
    Last Post: 22nd February 2010, 11:49
  4. Mounting a .zip file
    By jaclaz in forum Data Compression
    Replies: 7
    Last Post: 24th November 2008, 04:54
  5. QuickLZ ZIP - new zip/deflate library
    By Lasse Reinhold in forum Forum Archive
    Replies: 23
    Last Post: 1st October 2007, 22:08

Tags for this Thread

Posting Permissions

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