When compressing many PNG images into a 7z archive, the best method involves optimizing both the compression algorithm and settings to balance efficiency, speed, and compression ratio. Here's a detailed breakdown:
1. Best Algorithm: LZMA2
-
Why?
LZMA2 is the default and most efficient algorithm for 7z archives, especially for general-purpose data. It offers high compression ratios and good speed for most file types, including PNGs. While PNGs are already compressed, LZMA2 can still reduce the archive size by leveraging redundancy across files (e.g., similar pixel patterns in multiple images).
-
Other Algorithms (Less Common):
- PPMD: Offers slightly better compression for some data but is slower and uses more memory. Not ideal for large PNG collections.
- BZip2: Slower than LZMA2 and less efficient for PNGs.
- Deflate (ZIP): Less efficient than LZMA2 for PNGs.
Conclusion: Stick with LZMA2 unless you have specific needs (e.g., ultra-high compression for small datasets).
2. Optimal Settings for Multiple PNGs
Use these settings to maximize compression while maintaining reasonable speed:
Compression Level
-mx=9 (Maximum):
- Best for maximum compression (slower).
- Ideal if you prioritize smallest file size and can tolerate longer processing times.
-mx=5 (High):
- Balances compression and speed.
- Recommended for most use cases.
-mx=3 (Normal):
- Faster but less compression.
Solid Block Setting
-ss (Solid Archive):
- Compresses all files as a single block, improving compression for similar files (e.g., multiple PNGs).
- Enable this if your PNGs share common patterns (e.g., icons, screenshots).
- Example:
7z a -t7z -mx=9 -ss archive.7z *.png
Dictionary Size
-mdict=128M (or higher):
- Increases the dictionary size to improve compression for large files.
- Example:
7z a -t7z -mx=9 -mdict=128M archive.7z *.png
Additional Options
-m0=lzma2: Explicitly specify LZMA2 (default, but useful for clarity).
-mfb=64: Adjust the number of hashing bits (default is sufficient for most cases).
3. Command Line Example
To compress multiple PNGs into a 7z archive with maximum compression and solid block:
7z a -t7z -mx=9 -ss -mdict=128M archive.7z *.png
4. GUI Steps (7-Zip File Manager)
- Select all PNG files.
- Right-click > 7-Zip > Add to Archive....
- In the dialog:
- Archive format:
7z.
- Compression level: Set to "Ultra" or "Maximum".
- Solid block: Check "Solid".
- Dictionary size: Adjust if needed (default is fine for most cases).
- Click OK.
5. Key Considerations
- PNGs Are Already Compressed:
- Compression gains may be limited (e.g., 5–15% reduction).
- If you only need to store PNGs without further compression, use
-mx=0 (Store) to avoid unnecessary processing.
- Solid Archives:
- Best for similar files (e.g., many PNGs with overlapping data).
- Avoid if files are highly unique (e.g., different images with no common patterns).
- Speed vs. Compression:
- Use
-mx=5 for a balance.
- Use
-mx=9 for maximum compression (e.g., for long-term storage).
6. Alternative Tools
If 7z isn’t ideal, consider:
- ZIP + Deflate: Faster but worse compression.
- Tar + LZMA: For Linux users,
tar -I lzma can compress PNGs efficiently.
- WebP/AVIF: If you’re open to converting PNGs to newer formats, these offer better compression than 7z for images.
Summary
- Best Algorithm: LZMA2 (default in 7z).
- Recommended Settings:
7z a -t7z -mx=9 -ss -mdict=128M archive.7z *.png
- For speed:
7z a -t7z -mx=5 archive.7z *.png
- Solid Block: Enable for similar PNGs.
- Limitations: PNGs are already compressed, so gains are modest.
Let me know if you need help testing specific settings or comparing results! 📁✨