I discovered that ECT is overlooking a compression opportunity when processing ZIP files. ECT does not appear to attempt compression of stored files within archives. I have found this particularly with archived PNG and JPG files, as archivers focused on speed will often not attempt to compress them. If ECT encounters zip-stored PNG and JPG files, it will attempt optimization (unless --disable-png and --disable-jpg are declared), but WILL NOT then zip-compress them.
I just tested this with an Excel XLSM file containing embedded images in PNG and JPG formats. (I cannot share the file itself, as it contains confidential information.) I have used the AdvZIP CLI compressor (part of AdvanceCOMP here: https://www.advancemame.it/download) to list the ZIP contents with advzip -l. After compressing the XLSM file with "ECT -zip -9 -progressive", the archive contents are:
Length Method Size Ratio Date Time CRC-32 Name
-------- ------ ------- ----- ---- ---- ------ ----
4318 Defl:S 639 85% 01-01-80 00:00 8a7a7228 [Content_Types].xml
734 Defl:S 276 62% 01-01-80 00:00 cd891d31 _rels/.rels
5428 Defl:S 1522 71% 01-01-80 00:00 df199449 xl/workbook.xml
1767 Defl:S 608 65% 01-01-80 00:00 a938877a xl/drawings/drawing4.xml
1513 Defl:S 315 79% 01-01-80 00:00 f0045c10 xl/_rels/workbook.xml.rels
69073 Defl:S 10412 84% 01-01-80 00:00 7a8dc06e xl/worksheets/sheet1.xml
131742 Defl:S 17736 86% 01-01-80 00:00 fac20861 xl/worksheets/sheet2.xml
101989 Defl:S 13802 86% 01-01-80 00:00 479dc418 xl/worksheets/sheet3.xml
8102 Defl:S 1811 77% 01-01-80 00:00 5a14421e xl/worksheets/sheet4.xml
8725 Defl:S 1724 80% 01-01-80 00:00 625d4a1d xl/theme/theme1.xml
164075 Defl:S 7263 95% 01-01-80 00:00 06a2cb0b xl/styles.xml
33014 Defl:S 8006 75% 01-01-80 00:00 8e1008da xl/sharedStrings.xml
429 Defl:S 186 56% 01-01-80 00:00 3fa0f181 xl/drawings/_rels/drawing3.xml.rels
307 Defl:S 188 38% 01-01-80 00:00 c983da17 xl/charts/_rels/chart1.xml.rels
3858 Defl:S 1313 65% 01-01-80 00:00 936920d3 xl/drawings/drawing1.xml
26341 Defl:S 1807 93% 01-01-80 00:00 7d2418a7 xl/drawings/vmlDrawing1.vml
399 Defl:S 200 49% 01-01-80 00:00 81dc1b80 xl/charts/_rels/chart2.xml.rels
562 Defl:S 197 64% 01-01-80 00:00 9c1ab557 xl/drawings/_rels/drawing5.xml.rels
16827 Stored 16827 0% 01-01-80 00:00 2f6bf3ab xl/media/image1.jpeg
562 Defl:S 195 65% 01-01-80 00:00 fc9137d3 xl/drawings/_rels/vmlDrawing4.vml.rels
56520 Defl:S 2238 96% 01-01-80 00:00 bf63843a xl/drawings/drawing2.xml
38421 Defl:S 2451 93% 01-01-80 00:00 8a45d9d7 xl/drawings/vmlDrawing2.vml
23786 Defl:S 2011 91% 01-01-80 00:00 7cd469da xl/drawings/drawing3.xml
11299 Defl:S 1157 89% 01-01-80 00:00 a0d1da79 xl/drawings/vmlDrawing3.vml
7668 Defl:S 1537 79% 01-01-80 00:00 8a023b5d xl/charts/chart1.xml
8163 Defl:S 1973 75% 01-01-80 00:00 47e07429 xl/charts/chart2.xml
8823 Defl:S 971 88% 01-01-80 00:00 8aa4a9d0 xl/charts/style1.xml
794 Defl:S 224 71% 01-01-80 00:00 40bf1e19 xl/charts/colors1.xml
474112 Defl:S 433205 8% 01-01-80 00:00 95ef6237 xl/embeddings/oleObject2.bin
7776 Defl:S 1198 84% 01-01-80 00:00 d51e7ffb xl/drawings/drawing5.xml
2555 Defl:S 765 70% 01-01-80 00:00 ef6318a6 xl/drawings/vmlDrawing4.vml
316416 Defl:S 300902 4% 01-01-80 00:00 5415a6dd xl/embeddings/oleObject1.bin
5340 Defl:S 840 84% 01-01-80 00:00 6394b809 xl/media/image2.emf
83525 Defl:S 80119 4% 01-01-80 00:00 b51af164 xl/embeddings/Microsoft_Word_Document.docx
5636 Defl:S 766 86% 01-01-80 00:00 daf5a56a xl/media/image3.emf
5460 Defl:S 878 83% 01-01-80 00:00 e799f5f5 xl/media/image4.emf
98801 Stored 98801 0% 01-01-80 00:00 fccad0ff xl/media/image5.png
156636 Stored 156636 0% 01-01-80 00:00 8cd3598f xl/media/image6.png
55812 Stored 55812 0% 01-01-80 00:00 cb5c1bbc xl/media/image7.png
182272 Defl:S 73455 59% 01-01-80 00:00 b93ce9ec xl/vbaProject.bin
883 Defl:S 250 71% 01-01-80 00:00 a7232181 xl/worksheets/_rels/sheet1.xml.rels
747 Defl:S 237 68% 01-01-80 00:00 5d39eb8a xl/worksheets/_rels/sheet2.xml.rels
747 Defl:S 237 68% 01-01-80 00:00 598d152c xl/worksheets/_rels/sheet3.xml.rels
1473 Defl:S 322 78% 01-01-80 00:00 4da80893 xl/worksheets/_rels/sheet4.xml.rels
293 Defl:S 182 37% 01-01-80 00:00 8617eafd xl/drawings/_rels/drawing1.xml.rels
733 Defl:S 398 45% 01-01-80 00:00 b00d0090 xl/metadata.xml
1168 Defl:S 157 86% 01-01-80 00:00 55ad8aac xl/printerSettings/printerSettings1.bin
2364 Defl:S 909 61% 01-01-80 00:00 b9ece891 xl/tables/table1.xml
22770 Defl:S 5544 75% 01-01-80 00:00 222fccee xl/comments1.xml
5428 Defl:S 382 92% 01-01-80 00:00 282aa559 xl/printerSettings/printerSettings2.bin
6400 Defl:S 2118 66% 01-01-80 00:00 22f5c016 xl/comments3.xml
1191 Defl:S 486 59% 01-01-80 00:00 c5d41d20 docProps/app.xml
1168 Defl:S 157 86% 01-01-80 00:00 c98402f6 xl/printerSettings/printerSettings3.bin
28224 Defl:S 6859 75% 01-01-80 00:00 f0d328d1 xl/comments2.xml
16950 Defl:S 2112 87% 01-01-80 00:00 4b779463 xl/calcChain.xml
299 Defl:S 193 35% 01-01-80 00:00 87e1f355 docMetadata/LabelInfo.xml
1188 Defl:S 346 70% 01-01-80 00:00 99f5bf12 xl/printerSettings/printerSettings4.bin
708 Defl:S 352 50% 01-01-80 00:00 56563322 docProps/core.xml
-------- ------- --- -------
2222314 1322207 40% 58 files
The PNG files in particular have been optimized, but are still listed as Stored. If I then follow up with advzip -z1 (its cheapest, fastest compression algorithm) and list the contents again, they are as follows:
Length Method Size Ratio Date Time CRC-32 Name
-------- ------ ------- ----- ---- ---- ------ ----
4318 Defl:S 639 85% 01-01-80 00:00 8a7a7228 [Content_Types].xml
734 Defl:S 276 62% 01-01-80 00:00 cd891d31 _rels/.rels
5428 Defl:S 1522 71% 01-01-80 00:00 df199449 xl/workbook.xml
1767 Defl:S 608 65% 01-01-80 00:00 a938877a xl/drawings/drawing4.xml
1513 Defl:S 315 79% 01-01-80 00:00 f0045c10 xl/_rels/workbook.xml.rels
69073 Defl:S 10412 84% 01-01-80 00:00 7a8dc06e xl/worksheets/sheet1.xml
131742 Defl:S 17736 86% 01-01-80 00:00 fac20861 xl/worksheets/sheet2.xml
101989 Defl:S 13802 86% 01-01-80 00:00 479dc418 xl/worksheets/sheet3.xml
8102 Defl:S 1811 77% 01-01-80 00:00 5a14421e xl/worksheets/sheet4.xml
8725 Defl:S 1724 80% 01-01-80 00:00 625d4a1d xl/theme/theme1.xml
164075 Defl:S 7263 95% 01-01-80 00:00 06a2cb0b xl/styles.xml
33014 Defl:S 8006 75% 01-01-80 00:00 8e1008da xl/sharedStrings.xml
429 Defl:S 186 56% 01-01-80 00:00 3fa0f181 xl/drawings/_rels/drawing3.xml.rels
307 Defl:S 188 38% 01-01-80 00:00 c983da17 xl/charts/_rels/chart1.xml.rels
3858 Defl:S 1313 65% 01-01-80 00:00 936920d3 xl/drawings/drawing1.xml
26341 Defl:S 1807 93% 01-01-80 00:00 7d2418a7 xl/drawings/vmlDrawing1.vml
399 Defl:S 200 49% 01-01-80 00:00 81dc1b80 xl/charts/_rels/chart2.xml.rels
562 Defl:S 197 64% 01-01-80 00:00 9c1ab557 xl/drawings/_rels/drawing5.xml.rels
16827 Defl:X 16615 1% 01-01-80 00:00 2f6bf3ab xl/media/image1.jpeg
562 Defl:S 195 65% 01-01-80 00:00 fc9137d3 xl/drawings/_rels/vmlDrawing4.vml.rels
56520 Defl:S 2238 96% 01-01-80 00:00 bf63843a xl/drawings/drawing2.xml
38421 Defl:S 2451 93% 01-01-80 00:00 8a45d9d7 xl/drawings/vmlDrawing2.vml
23786 Defl:S 2011 91% 01-01-80 00:00 7cd469da xl/drawings/drawing3.xml
11299 Defl:S 1157 89% 01-01-80 00:00 a0d1da79 xl/drawings/vmlDrawing3.vml
7668 Defl:S 1537 79% 01-01-80 00:00 8a023b5d xl/charts/chart1.xml
8163 Defl:S 1973 75% 01-01-80 00:00 47e07429 xl/charts/chart2.xml
8823 Defl:S 971 88% 01-01-80 00:00 8aa4a9d0 xl/charts/style1.xml
794 Defl:S 224 71% 01-01-80 00:00 40bf1e19 xl/charts/colors1.xml
474112 Defl:S 433205 8% 01-01-80 00:00 95ef6237 xl/embeddings/oleObject2.bin
7776 Defl:S 1198 84% 01-01-80 00:00 d51e7ffb xl/drawings/drawing5.xml
2555 Defl:S 765 70% 01-01-80 00:00 ef6318a6 xl/drawings/vmlDrawing4.vml
316416 Defl:S 300902 4% 01-01-80 00:00 5415a6dd xl/embeddings/oleObject1.bin
5340 Defl:S 840 84% 01-01-80 00:00 6394b809 xl/media/image2.emf
83525 Defl:S 80119 4% 01-01-80 00:00 b51af164 xl/embeddings/Microsoft_Word_Document.docx
5636 Defl:S 766 86% 01-01-80 00:00 daf5a56a xl/media/image3.emf
5460 Defl:S 878 83% 01-01-80 00:00 e799f5f5 xl/media/image4.emf
98801 Defl:X 96534 2% 01-01-80 00:00 fccad0ff xl/media/image5.png
156636 Defl:X 138339 11% 01-01-80 00:00 8cd3598f xl/media/image6.png
55812 Defl:X 53812 3% 01-01-80 00:00 cb5c1bbc xl/media/image7.png
182272 Defl:S 73455 59% 01-01-80 00:00 b93ce9ec xl/vbaProject.bin
883 Defl:S 250 71% 01-01-80 00:00 a7232181 xl/worksheets/_rels/sheet1.xml.rels
747 Defl:S 237 68% 01-01-80 00:00 5d39eb8a xl/worksheets/_rels/sheet2.xml.rels
747 Defl:S 237 68% 01-01-80 00:00 598d152c xl/worksheets/_rels/sheet3.xml.rels
1473 Defl:S 322 78% 01-01-80 00:00 4da80893 xl/worksheets/_rels/sheet4.xml.rels
293 Defl:S 182 37% 01-01-80 00:00 8617eafd xl/drawings/_rels/drawing1.xml.rels
733 Defl:S 398 45% 01-01-80 00:00 b00d0090 xl/metadata.xml
1168 Defl:S 157 86% 01-01-80 00:00 55ad8aac xl/printerSettings/printerSettings1.bin
2364 Defl:S 909 61% 01-01-80 00:00 b9ece891 xl/tables/table1.xml
22770 Defl:S 5544 75% 01-01-80 00:00 222fccee xl/comments1.xml
5428 Defl:S 382 92% 01-01-80 00:00 282aa559 xl/printerSettings/printerSettings2.bin
6400 Defl:S 2118 66% 01-01-80 00:00 22f5c016 xl/comments3.xml
1191 Defl:S 486 59% 01-01-80 00:00 c5d41d20 docProps/app.xml
1168 Defl:S 157 86% 01-01-80 00:00 c98402f6 xl/printerSettings/printerSettings3.bin
28224 Defl:S 6859 75% 01-01-80 00:00 f0d328d1 xl/comments2.xml
16950 Defl:S 2112 87% 01-01-80 00:00 4b779463 xl/calcChain.xml
299 Defl:S 193 35% 01-01-80 00:00 87e1f355 docMetadata/LabelInfo.xml
1188 Defl:S 346 70% 01-01-80 00:00 99f5bf12 xl/printerSettings/printerSettings4.bin
708 Defl:S 352 50% 01-01-80 00:00 56563322 docProps/core.xml
-------- ------- --- -------
2222314 1299431 41% 58 files
This is over 22KB of space gained by a poor ZIP algorithm over ECT's best, simply because it was willing to work on stored files. Running ECT again on the same archive, it is then able to further compress the now-compressed images.
If I instead run advzip -z1 first (on a pristine, unoptimized copy of the XLSM so that none of the archived files are stored) followed by ECT -zip -9 -progressive, ECT is able to optimize and ZIP-compress the images in one shot.
I haven't tried it, but I suspect this will also affect ZIP archives containing other ZIP archives.
I discovered that ECT is overlooking a compression opportunity when processing ZIP files. ECT does not appear to attempt compression of stored files within archives. I have found this particularly with archived PNG and JPG files, as archivers focused on speed will often not attempt to compress them. If ECT encounters zip-stored PNG and JPG files, it will attempt optimization (unless --disable-png and --disable-jpg are declared), but WILL NOT then zip-compress them.
I just tested this with an Excel XLSM file containing embedded images in PNG and JPG formats. (I cannot share the file itself, as it contains confidential information.) I have used the AdvZIP CLI compressor (part of AdvanceCOMP here: https://www.advancemame.it/download) to list the ZIP contents with advzip -l. After compressing the XLSM file with "ECT -zip -9 -progressive", the archive contents are:
The PNG files in particular have been optimized, but are still listed as Stored. If I then follow up with advzip -z1 (its cheapest, fastest compression algorithm) and list the contents again, they are as follows:
This is over 22KB of space gained by a poor ZIP algorithm over ECT's best, simply because it was willing to work on stored files. Running ECT again on the same archive, it is then able to further compress the now-compressed images.
If I instead run advzip -z1 first (on a pristine, unoptimized copy of the XLSM so that none of the archived files are stored) followed by ECT -zip -9 -progressive, ECT is able to optimize and ZIP-compress the images in one shot.
I haven't tried it, but I suspect this will also affect ZIP archives containing other ZIP archives.