最近用plplot画图,其cairo ps库生成的ps图片总是不能合理地剪切掉多余的边框,于是乎自己写了一个小脚本epscrop,用修改ps图的BoundingBox.

#!/bin/bash

# check if the argument is provided.
if [ $# -lt 1 ]
then
  echo "no file specified."
  exit
fi

fname=$1

#check if the file exits.
if [ ! -f $fname ]
then
  echo "file $fname not exists."
  exit
fi

#get the bounding box
box=$(gs -sstderr=%stdout -dQUIET -dBATCH -DNOPAUSE -sDEVICE=bbox $fname 2>&1 | sed -n -e "s/%%BoundingBox:\(.*\)/\1/p")

#change the bounding box
sed -i -e "/%%DocumentMedia:/d" $fname
sed -i -e "s/\(%%BoundingBox:\)\(.*\)/\1$box/" -e "s/\(%%PageBoundingBox:\)\(.*\)/\1$box/" $fname

 用法: ./epscrop psfile,   效果如下,

剪切Postscript图片中的多余边框      剪切Postscript图片中的多余边框

相关文章:

  • 2021-12-29
  • 2022-12-23
  • 2021-11-29
  • 2021-07-06
  • 2021-12-03
  • 2021-12-26
  • 2021-12-10
猜你喜欢
  • 2021-05-25
  • 2022-01-12
  • 2022-01-08
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案