diff --git a/lib/ChangeLog b/lib/ChangeLog index 4c6e8b097e..14607b25aa 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2002-10-18 Angus Leeming + + * scripts/lyxpreview2bitmap.sh: Use pnmcrop to crop the images + if so desired. + 2002-10-16 Jean-Marc Lasgouttes * configure.m4: add mozilla as default previewer for html diff --git a/lib/scripts/lyxpreview2bitmap.sh b/lib/scripts/lyxpreview2bitmap.sh index 6e338fe33d..9744f16877 100644 --- a/lib/scripts/lyxpreview2bitmap.sh +++ b/lib/scripts/lyxpreview2bitmap.sh @@ -196,3 +196,28 @@ fi FILES=`ls ${BASE}* | sed -e "/${BASE}.metrics/d" \ -e "/${BASE}\([0-9]*\).${GSSUFFIX}/d"` rm -f ${FILES} texput.log + +# The bitmap files can have large amounts of whitespace to the left and +# right. This can be cropped if so desired. +CROP=1 + +which pnmcrop > /dev/null +if [ $? -ne 0 ]; then + CROP=0 +fi + +# There's no point cropping the image if using PNG images. If you want to +# crop, use PPM. +# Apparently dvipng will support cropping at some stage in the future... +if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then + for FILE in ${BASE}*.${GSSUFFIX} + do + pnmcrop -left ${FILE} | pnmcrop -right ${FILE} > ${BASE}.tmp + if [ $? -eq 0 ]; then + mv ${BASE}.tmp ${FILE} + else + rm -f ${BASE}.tmp + fi + done + rm -f ${BASE}.tmp +fi