Expanding upon William's answer, one could calculate the end of the last partition using
fdisk and a calculator:
$ fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00057540
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 186367 184320 90M c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 3667967 3481600 1.7G 5 Extended
/dev/mmcblk0p5 188416 3667967 3479552 1.7G 83 Linux
Total used space in bytes = end sector of last partition X sector size (here that's 3667967 x 512).
Total used space in GB = total used space in bytes / 10243 (here that's 1.749023 GB).
Usually, it is not vital to create an image that is pared right down to the last useful bit of data so in the above example I would create an image of 2 GB using the method described by William in that same earlier answer:
dd if=/dev/mmcblk0 of=/path/to/pi_updated.img bs=1M count=2048
Included at the end of the image will be a small portion of the useless guff after your last useful data but that is no different in principle than the useless guff that will be overwritten when you write the image back out to your media.
This method has been working for me on a dozen or so clones. If there are any fatal flaws in this method, they haven't surfaced yet.