Browse Source

v2.4.1 - Backgrounding2 - RGB fix; rgb processing is now fixed on 255-based numbers which are converted internally to percentage-based numbers; there is currently no way to pass percentage-based RGB directly; should implement color-hsb param to use with RGB; edited help and readme to say we need 255-based numbers for RGB. CMYK mode is preferred over any other.

master
parent
commit
cc691a9df8
2 changed files with 16 additions and 13 deletions
  1. +3
    -3
      README.md
  2. +13
    -10
      pdfScale.sh

+ 3
- 3
README.md View File

@@ -127,7 +127,7 @@ $ pdfscale -v -v -r 'custom mm 200 300' -f disable -s 0.95 ../mixsync\ manual\ v
## Help info ## Help info
``` ```
$ pdfscale -h $ pdfscale -h
pdfscale v2.4.0
pdfscale v2.4.1


Usage: pdfscale <inFile.pdf> Usage: pdfscale <inFile.pdf>
pdfscale -i <inFile.pdf> pdfscale -i <inFile.pdf>
@@ -226,8 +226,6 @@ Parameters:
--background-rgb <"R G B"> --background-rgb <"R G B">
Creates a background with a RGB color setting Creates a background with a RGB color setting
Must be quoted into a single parameter as in "100 100 200" 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) RGB numbers are integers between 0 and 255 (255 122 50)
--dry-run, --simulate --dry-run, --simulate
Just simulate execution. Will not run ghostscript Just simulate execution. Will not run ghostscript
@@ -313,6 +311,8 @@ Examples:
pdfscale -v -v -m i -s 0.7 myPdfFile.pdf pdfscale -v -v -m i -s 0.7 myPdfFile.pdf
pdfscale -r A4 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" pdfscale -v -v -r "custom mm 252 356" -s 0.9 -f "../input file.pdf" "../my new pdf"


``` ```
## Standard Paper Tables ## Standard Paper Tables


+ 13
- 10
pdfScale.sh View File

@@ -13,7 +13,7 @@
# And: https://gist.github.com/MichaelJCole/86e4968dbfc13256228a # And: https://gist.github.com/MichaelJCole/86e4968dbfc13256228a




VERSION="2.4.0"
VERSION="2.4.1"




###################### EXTERNAL PROGRAMS ####################### ###################### EXTERNAL PROGRAMS #######################
@@ -1259,24 +1259,29 @@ parseCMYKBackground() {


# Just loads the RGB Vars (without testing anything) # Just loads the RGB Vars (without testing anything)
loadRGBVars(){ 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! BACKGROUNDCALL="$BACKGROUNDCOLOR setrgbcolor clippath fill " # the space at the end is important!
BACKGROUNDTYPE="RGB" 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 # Parse RGB Background color
parseRGBBackground() { parseRGBBackground() {
if isFloatPercentage "$1" && isFloatPercentage "$2" && isFloatPercentage "$3" ; then
loadRGBVars "$1" "$2" "$3"
return $TRUE
fi
if isRGBInteger "$1" && isRGBInteger "$2" && isRGBInteger "$3" ; then if isRGBInteger "$1" && isRGBInteger "$2" && isRGBInteger "$3" ; then
loadRGBVars "$1" "$2" "$3" loadRGBVars "$1" "$2" "$3"
return $TRUE return $TRUE
fi fi
printError "Invalid RGB Background colors. Need 3 parameters in RGB order." 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 "Eg: --background-rgb \"34 123 255\""
printError " [R] => $1" printError " [R] => $1"
printError " [G] => $2" printError " [G] => $2"
@@ -2123,8 +2128,6 @@ Parameters:
--background-rgb <\"R G B\"> --background-rgb <\"R G B\">
Creates a background with a RGB color setting Creates a background with a RGB color setting
Must be quoted into a single parameter as in \"100 100 200\" 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) RGB numbers are integers between 0 and 255 (255 122 50)
--dry-run, --simulate --dry-run, --simulate
Just simulate execution. Will not run ghostscript Just simulate execution. Will not run ghostscript


Loading…
Cancel
Save