From 0cf115854c500f06daad2b583dfcf2bd0a716f4d Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 8 Jul 2002 11:57:30 +0000 Subject: [PATCH] Add an option to crop to the left and to the right of the images if so desired. Add some blurb to the top of the script. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4546 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 ++++ lib/scripts/lyxpreview2ppm.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/ChangeLog b/lib/ChangeLog index 8cbde0b3f1..67a4e1bb69 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2002-07-08 Angus Leeming + + * scripts/lyxpreview2ppm.sh: added blurb. Crop the images to the + left and right if so desired. 2002-07-08 André Pönitz diff --git a/lib/scripts/lyxpreview2ppm.sh b/lib/scripts/lyxpreview2ppm.sh index e6622432e8..38c75186f3 100644 --- a/lib/scripts/lyxpreview2ppm.sh +++ b/lib/scripts/lyxpreview2ppm.sh @@ -1,4 +1,14 @@ #!/bin/sh +# +# \file lyxpreview2ppm.sh +# Copyright 2002 the LyX Team +# Read the file COPYING +# +# \author Angus Leeming, leeming@lyx.org +# +# with much help from David Kastrup, david.kastrup@t-online.de. +# The sed script was created with advice from Praveen D V +# and the sed users' list sed-users@yahoogroups.com. # This script takes a LaTeX file and generates PPM files, one per page. # The idea is to use it with preview.sty to create small bitmap previews of @@ -105,6 +115,30 @@ STATUS=$? rm -f ${SEDSCRIPT} EXECUTABLE="extracting metrics"; CHECK_STATUS +# The ppm files have spurious (?! say some !) white space on the left and right +# sides. If you don't want this set REMOVE_WS=0. +REMOVE_WS=1 + +which pnmcrop > /dev/null +STATUS=$? + +if [ ${STATUS} -ne 0 ]; then + REMOVE_WS=0 +fi + +if [ REMOVE_WS -eq 1 ]; then + TMP=.${BASE}.ppm + for FILE=`ls ${BASE}???.ppm` + do + pnmcrop -left -right ${FILE} > ${TMP} + STATUS=$? + if [ ${STATUS} -eq 0 ]; then + mv -f ${TMP} ${FILE} + fi + done + rm -f ${TMP} +fi + # All was successful, so remove everything except the ppm files and the # metrics file. FILES=`ls ${BASE}* | sed -e "/${BASE}.metrics/d" -e "/${BASE}.*.ppm/d"` -- 2.39.2