summaryrefslogtreecommitdiff
path: root/contrib/pic2graph
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2018-04-23 04:14:55 -0400
committerG. Branden Robinson <g.branden.robinson@gmail.com>2018-04-23 04:27:01 -0400
commitb60f6b6d0c0a9655d10d32ee6688ac0f45fc3006 (patch)
tree5d4e599d280dde5b4188249c86c285b0d8fe8d97 /contrib/pic2graph
parentb472be1d77204c0ab420ef95e3e5e3772562e328 (diff)
downloadgroff-git-b60f6b6d0c0a9655d10d32ee6688ac0f45fc3006.tar.gz
pic2graph: Adapt to old convert(1) programs.
* contrib/pic2graph/pic2graph.sh: Grep convert's -help output for the string "-trim". If it is not found, the old method for image trimming documented in pic2graph's man page, "-crop 0x0", is used. I am motivated by the fact that the warning about this in our man page is very old (10 years or more), and I wanted to get rid of it. pic2graph emits a warning when performing this fallback, in the event the ImageMagick and/or GraphicsMagick teams surprise the world again. * contrib/pic2graph/pic2graph.1.man: Remove BUGS section, the entire contents of which was dedicated to convert's change in behavior. NEWS: * Add Emacs fill-column. * Add Vim modeline. * Wrap the few lines in this file that were longer that 76 columns (about 6 out of almost 2,900) and reflow their paragraphs. Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>
Diffstat (limited to 'contrib/pic2graph')
-rw-r--r--contrib/pic2graph/pic2graph.1.man26
-rw-r--r--contrib/pic2graph/pic2graph.sh13
2 files changed, 12 insertions, 27 deletions
diff --git a/contrib/pic2graph/pic2graph.1.man b/contrib/pic2graph/pic2graph.1.man
index 42f5ecc62..b9ea5c3a8 100644
--- a/contrib/pic2graph/pic2graph.1.man
+++ b/contrib/pic2graph/pic2graph.1.man
@@ -177,32 +177,6 @@ Otherwise, temporary files will be created in
.
.
.\" ====================================================================
-.SH BUGS
-.\" ====================================================================
-.
-Due to changes in the behavior of ImageMagick
-.BR \%convert (1)
-that are both forward and backward-incompatible,
-mismatches between your
-.B pic2graph
-and
-.BR \%convert (1)
-versions may produce zero-sized or untrimmed output images.
-.
-For this version of
-.B pic2graph
-you will need a version of
-.BR \%convert (1)
-that supports the
-.B \-trim
-option; older versions of
-.B pic2graph
-used
-.BR \-crop\~0x0 ,
-which no longer has trimming behavior.
-.
-.
-.\" ====================================================================
.SH AUTHORS
.\" ====================================================================
.B pic2graph
diff --git a/contrib/pic2graph/pic2graph.sh b/contrib/pic2graph/pic2graph.sh
index fd3c4c998..7773b2675 100644
--- a/contrib/pic2graph/pic2graph.sh
+++ b/contrib/pic2graph/pic2graph.sh
@@ -34,6 +34,7 @@
#
groffpic_opts=""
convert_opts=""
+convert_trim_arg="-trim"
format="png"
eqndelim='$$'
@@ -83,6 +84,15 @@ if test -z "$tmp"; then
{ (exit 1); exit 1; }
fi
+# See if the installed version of convert(1) is new enough to support the -trim
+# option. Versions that didn't were described as "old" as early as 2008.
+is_convert_recent=`convert -help | grep -e -trim`
+if test -z "$is_convert_recent"
+then
+ echo "$0: warning: falling back to old '-crop 0x0' trim method" >&2
+ convert_trim_arg="-crop 0x0"
+fi
+
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' EXIT INT TERM
# Here goes:
@@ -92,7 +102,8 @@ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' EXIT INT TERM
# 4. Use convert(1) to crop the PostScript and turn it into a bitmap.
(echo ".EQ"; echo $eqndelim; echo ".EN"; echo ".PS"; cat; echo ".PE") | \
groff -e -p $groffpic_opts -Tps -P-pletter > $tmp/pic2graph.ps \
- && convert -trim $convert_opts $tmp/pic2graph.ps $tmp/pic2graph.$format \
+ && convert $convert_trim_arg $convert_opts $tmp/pic2graph.ps \
+ $tmp/pic2graph.$format \
&& cat $tmp/pic2graph.$format
# End