I currently use hdiutil
to create my DMGs.
The command I use is hdiutil create -size xxxg myImage.dmg -fs HFS+.
I'm always left fidgeting around with the size until I get it close enough.
Is there a better method that either shrinks the DMG to size or creates it size?
You can create a larger dmg, add the files, then resize it:
or create a sparseimage, and then convert it
I've never tried the latter, not sure if it'll pick the right size for the dmg.
Source: http://nickcharlton.net/post/converting-a-sparseimage-to-a-dmg
Note that sparseimages need to be compacted if files are deleted from them, as they don't release the space from deleted files automatically: