Okay... That took a little more time than expected and I admit it can be a lot more advanced, but I wrote this shell script that should do it automatically:
#!/bin/bash
# shrink-Bpi-m3-img.sh - Shell script to shrink a BananaPi M3 image
# the trick is to downsize the ext4 fs in the second partition
# Sizes for old and new filesystems in megabytes:
ORIG_FS_SIZE=7100
NEW_FS_SIZE=3500
if [ $# -gt 0 ]; then
if [ -f $1 ]; then
IMG=$1
else
echo "Usage: $(basename $0) <image file>" 1>&2
exit 1
fi
else
IMG=2016-05-14-dietpi-preview-bpi-m3-sd-emmc.img
fi
echo Using image file $IMG
EXTFS_IMG=$IMG.extfs
NEW_IMG=$IMG.new
# Extract the etx4 fs in the second partition of the image:
dd if=$IMG bs=1M count=$ORIG_FS_SIZE skip=356 of=$EXTFS_IMG
# Do a file system check so resize2fs won't complain:
/sbin/e2fsck -f $EXTFS_IMG
# Halve the size of the filesystem image:
/sbin/resize2fs $EXTFS_IMG ${NEW_FS_SIZE}M
# Recheck/clean the downsized filesystem
/sbin/e2fsck -f $EXTFS_IMG
# Now create a new image; start with the original "head":
dd if=$IMG bs=1M count=356 of=$NEW_IMG
# Append the resized image:
dd if=$EXTFS_IMG bs=1M count=$NEW_FS_SIZE >> $NEW_IMG
# Update the partition table of the image:
cat << EOT | /sbin/sfdisk -f $NEW_IMG
# partition table of 2016-05-14-dietpi-preview-bpi-m3-sd-emmc.img
unit: sectors
${NEW_IMG}1 : start= 204800, size= 524288, Id= c, bootable
${NEW_IMG}2 : start= 729088, size= $((NEW_FS_SIZE * 2048)), Id=83
${NEW_IMG}3 : start= 0, size= 0, Id= 0
${NEW_IMG}4 : start= 0, size= 0, Id= 0
EOT
# Do cleanup:
rm $EXTFS_IMG
# And it's done!