开发者

Calculating hdiutil's compression ratio

开发者 https://www.devze.com 2022-12-08 08:20 出处:网络
In my app I\'m using Apple\'s开发者_开发问答 hdiutil command line utility to create compressed disk images (DMGs) of folders/volumes. Is there any way to calculate the compressed size of a given sourc

In my app I'm using Apple's开发者_开发问答 hdiutil command line utility to create compressed disk images (DMGs) of folders/volumes. Is there any way to calculate the compressed size of a given source path? I've already checked in the man pages, nothing there.


Can you just compare the size of the disk image vs the size reported by either df (reporing the size of the volume) or du (reporting the size of files in a directory)?


hdiutil imageinfo /PATH/TO/IMAGE | grep 'Compressed Ratio'

Example Output:

Compressed Ratio: 0.14393602843180808

Meaning the disk image is 14% of the size of the original. This is using the standard zlib compression (UDZO) on a folder containing just text files however, so the compression amount is much higher than normal.


Choose Jamie Macey -- his answer is the right one. Use du -s to get your tree size, compare it to the size of the .dmg file.

0

精彩评论

暂无评论...
验证码 换一张
取 消