diff --git a/README.md b/README.md index 0c5a755..d265a80 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ $ pdfscale -v -v -r 'custom mm 200 300' -f disable -s 0.95 ../mixsync\ manual\ v ## Help info ``` $ pdfscale -h -pdfscale v2.4.0 +pdfscale v2.4.1 Usage: pdfscale pdfscale -i @@ -226,8 +226,6 @@ Parameters: --background-rgb <"R G B"> Creates a background with a RGB color setting Must be quoted into a single parameter as in "100 100 200" - Postscript accepts both percentages or RGB numbers, but not mixed - Percentages are floating point numbers between 0 and 1 (1 0.5 0.2) RGB numbers are integers between 0 and 255 (255 122 50) --dry-run, --simulate Just simulate execution. Will not run ghostscript @@ -313,6 +311,8 @@ Examples: pdfscale -v -v -m i -s 0.7 myPdfFile.pdf pdfscale -r A4 myPdfFile.pdf pdfscale -v -v -r "custom mm 252 356" -s 0.9 -f "../input file.pdf" "../my new pdf" + + ``` ## Standard Paper Tables diff --git a/pdfScale.sh b/pdfScale.sh index 30d8dfb..2229ddd 100755 --- a/pdfScale.sh +++ b/pdfScale.sh @@ -13,7 +13,7 @@ # And: https://gist.github.com/MichaelJCole/86e4968dbfc13256228a -VERSION="2.4.0" +VERSION="2.4.1" ###################### EXTERNAL PROGRAMS ####################### @@ -1259,24 +1259,29 @@ parseCMYKBackground() { # Just loads the RGB Vars (without testing anything) loadRGBVars(){ - BACKGROUNDCOLOR="$1 $2 $3" + local rP="$(rgbToPercentage $1)" + local gP="$(rgbToPercentage $2)" + local bP="$(rgbToPercentage $3)" + BACKGROUNDCOLOR="$rP $gP $bP" BACKGROUNDCALL="$BACKGROUNDCOLOR setrgbcolor clippath fill " # the space at the end is important! BACKGROUNDTYPE="RGB" - BACKGROUNDLOG="$BACKGROUNDTYPE Mode > $BACKGROUNDCOLOR" + BACKGROUNDLOG="$BACKGROUNDTYPE Mode > $1($(printf %.2f $rP)) $2($(printf %.2f $gP)) $3($(printf %.2f $bP))" +} + +# Converts 255-based RGB to Percentage +rgbToPercentage() { + local per=$(echo "scale=8; $1 / 255" | "$BCBIN") + printf '%.7f' "$per" # Print rounded conversion } # Parse RGB Background color parseRGBBackground() { - if isFloatPercentage "$1" && isFloatPercentage "$2" && isFloatPercentage "$3" ; then - loadRGBVars "$1" "$2" "$3" - return $TRUE - fi if isRGBInteger "$1" && isRGBInteger "$2" && isRGBInteger "$3" ; then loadRGBVars "$1" "$2" "$3" return $TRUE fi printError "Invalid RGB Background colors. Need 3 parameters in RGB order." - printError "Numbers can be EITHER percentages between 0 and 1 or RGB integers between 0 and 255." + printError "Numbers must be RGB integers between 0 and 255." printError "Eg: --background-rgb \"34 123 255\"" printError " [R] => $1" printError " [G] => $2" @@ -2123,8 +2128,6 @@ Parameters: --background-rgb <\"R G B\"> Creates a background with a RGB color setting Must be quoted into a single parameter as in \"100 100 200\" - Postscript accepts both percentages or RGB numbers, but not mixed - Percentages are floating point numbers between 0 and 1 (1 0.5 0.2) RGB numbers are integers between 0 and 255 (255 122 50) --dry-run, --simulate Just simulate execution. Will not run ghostscript