Is there a way to add JPG Files to a ZIP Archive without recompressing them? Sounds weird I know.
Creating a ZIP File via PHP uses lots of CPU. Using ZIP with no comprssion still uses lots of CPU. If I only want to add Images (JPG) to the Archive, why should they be recompressed when the JPGs are already compressed?
I know that every file in a ZIP Archive needs to be in a different Format (compressed) than the original File, but maybe there is a way to only set some headers in front of every file (without recompression) and copy those together to a ZIP Archive.
Since you have tagged this php
, I'll assume that your question applies to the PHP zip extension, in which case the answer is:
No there isn't.
The PHP zip extension does not currently allow you to set the compression method. (The bug has been open for several years and was still unresolved as of Jan 2012).
ZipArchive doesn't allow this (as far as I'm aware, although the extension isn't fully documented in the php.net manual).
However, the PCLZip library does allow a PCLZIP_OPT_NO_COMPRESSION argument when adding a file to a zip.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With