compression method for .dmg

1.2k views Asked by At

I want to compress a .app folder to a .dmg

I used bzip2 (-format UDBZ) to do that but the filesize is still too large and I know it can be done better. Is there a better compression algorythm available? Can I use 7zip (LZMA)?

2

There are 2 answers

0
Yuji On BEST ANSWER

I'm afraid not. The official documentation of hdiutil is here, and only zlib and bzip2 are available.

How big is it, by the way? What is taking up most of the space? Try to shrink down the size of .app itself.

By the way, from my personal interaction with non-techie users, I can testify that packing .app into .dmg is a very confusing concept for them... They don't understand what a disk image is, and what it means it is mounted as a disk. It would be easier for them to understand if .app is just zipped or bzip2'ed, which would be automatically decompressed when downloaded from the web.

0
Mingye Wang On

In the year 2024: yes there is one: lzma. We now have the following compressed formats:

  • UDCO - UDIF ADC-compressed image
  • UDZO - UDIF zlib-compressed image
  • ULFO - UDIF lzfse-compressed image (OS X 10.11+ only, that's 2015)
  • ULMO - UDIF lzma-compressed image (macOS 10.15+ only, that's 2019)
  • UDBZ - UDIF bzip2-compressed image (deprecated, OS X 10.4+ only)

Of these, your best chance for more ratio is ULMO.

You can also try adding a compression level. -imagekey bzip2-level=9 might just be what you need to push it a little further. However, bzip2 is atrociously slow to decompress, regardless of level; your users will scream and cry. It's deprecated for a reason.

None of the other things likely provide improved compression.

  • UDCO is extremely basic, nope.
  • UDZO is just deflate. Old, fast, but weak in ratios. It has -imagekey zlib-level=9, which makes it a little less weak.
  • ULFO is new, EVEN FASTER, but about as weak as UDZO -- think of it as being just a little worse than zstd. There is no level option.