pdfs to images script

This commit is contained in:
Sagar Karandikar 2018-05-19 19:09:37 +00:00
parent 40eb90f9b4
commit 1984e2600a
1 changed files with 36 additions and 0 deletions

36
docs/tools/pdfs_to_images.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
# this converts PDF images to pngs for use in docs
# requires that you install imagemagick
# sudo yum -y install ImageMagick
set -o xtrace
BASEPATH=$1
function outputimage() {
# first arg is filename, second arg is output name
convert -density 600 $1 -quality 100 $2.png
}
function get_path() {
# in the base directory given as first arg, return the path of the file
# with filename given in the second arg
FNAMEPATH=$(find $1 -type f -name "*$2")
echo $FNAMEPATH
}
function producepng() {
# first arg is pdf filename
SOURCEPATH=$(get_path $1 $2)
outputimage $SOURCEPATH $2
}
# $1 is starting path
GOTPATH=$(get_path $1 "95th-memcached-request-latency.pdf")
echo $GOTPATH
producepng $BASEPATH "95th-memcached-request-latency.pdf"