Move fourcell scripts into directory. Correctly orient ratio.
This commit is contained in:
parent
9d235be9da
commit
10c0266750
|
@ -70,7 +70,7 @@ get_outer_ratio_frame () {
|
|||
DBX=$(echo "${DX}-${BX}" | bc)
|
||||
ACY=$(echo "${AY}-${CY}" | bc)
|
||||
DBY=$(echo "${DY}-${BY}" | bc)
|
||||
echo "scale=4;((${ACY}+${DBY})/2) / ((${ACX}+${DBX})/2)" | bc
|
||||
echo "scale=4;((${ACX}+${DBX})/2) / ((${ACY}+${DBY})/2)" | bc
|
||||
}
|
||||
|
||||
get_outer_ratio () {
|
||||
|
|
21
fourcell.sh
21
fourcell.sh
|
@ -36,10 +36,10 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
tiff_name () {
|
||||
img_name () {
|
||||
filename=$(basename "${1}")
|
||||
filename="${filename%.*}"
|
||||
echo "${filename}.tif"
|
||||
echo "${filename}.png"
|
||||
}
|
||||
|
||||
echo "Using frames in ${OUTPUT}..."
|
||||
|
@ -48,6 +48,7 @@ W=$(cat "${1}" | jq -r ".width")
|
|||
H=$(cat "${1}" | jq -r ".height")
|
||||
DPI=$(echo "${W}/8.5" | bc)
|
||||
FRAMES=$(mktemp)
|
||||
RATIO=$(bash fourcell/template_ratio.sh "${1}")
|
||||
|
||||
echo "DPI: $DPI"
|
||||
|
||||
|
@ -64,29 +65,29 @@ for ((i=0;i<${PAGES};++i)); do
|
|||
f4=$(sed -n "$(((i*4)+4))p" < "${FRAMES}")
|
||||
args=""
|
||||
if [[ "${f1}" != "" ]]; then
|
||||
name=$(tiff_name "${f1}")
|
||||
name=$(img_name "${f1}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f1}" "${dest}"
|
||||
bash fourcell/white_fourcell.sh $DPI $RATIO "${f1}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
if [[ "${f2}" != "" ]]; then
|
||||
name=$(tiff_name "${f2}")
|
||||
name=$(img_name "${f2}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f2}" "${dest}"
|
||||
bash fourcell/white_fourcell.sh $DPI $RATIO "${f2}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
if [[ "${f3}" != "" ]]; then
|
||||
name=$(tiff_name "${f3}")
|
||||
name=$(img_name "${f3}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f3}" "${dest}"
|
||||
bash fourcell/white_fourcell.sh $DPI $RATIO "${f3}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
if [[ "${f4}" != "" ]]; then
|
||||
name=$(tiff_name "${f4}")
|
||||
name=$(img_name "${f4}")
|
||||
dest="${TMP}/${name}"
|
||||
bash white_fourcell.sh $DPI "${f4}" "${dest}"
|
||||
bash fourcell/white_fourcell.sh $DPI $RATIO "${f4}" "${dest}"
|
||||
args="${args} ${dest}"
|
||||
fi
|
||||
bash apply_image.sh ${3}/page_$i.tiff "${1}" ${args}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
bash fourcell.sh ~/Desktop/running/shot1-scans/image-3-normal.png.template.json ~/Desktop/countdown1/ ~/Desktop/pages/
|
|
@ -22,29 +22,36 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${2}" == "" ]]; then
|
||||
echo "Please provide input image as second argument"
|
||||
if [[ "${2}" != "" ]]; then
|
||||
OUTER=${2}
|
||||
else
|
||||
echo "Please provide outer ratio as second argument"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "${3}" == "" ]]; then
|
||||
echo "Please provide output image as third argument"
|
||||
echo "Please provide input image as third argument"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
DIM=$(identify -ping -format '%w %h' "${2}")
|
||||
if [[ "${4}" == "" ]]; then
|
||||
echo "Please provide output image as fourth argument"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
DIM=$(identify -ping -format '%w %h' "${3}")
|
||||
WIDTH=$(echo ${DIM} | awk '{print $1}')
|
||||
HEIGHT=$(echo ${DIM} | awk '{print $2}')
|
||||
R=$(echo "scale=${DIGITS};${HEIGHT}/${WIDTH}" | bc)
|
||||
OW=$(echo "scale=${DIGITS};${DPI}*(404/96)" | bc | awk -F'.' '{print $1}')
|
||||
OH=$(echo "scale=${DIGITS};${DPI}*(374/96)" | bc | awk -F'.' '{print $1}')
|
||||
OH=$(echo "scale=${DIGITS};${OW}*${OUTER}" | bc | awk -F'.' '{print $1}')
|
||||
IW=$(echo "scale=${DIGITS};${OW}*${SCALE}" | bc | awk -F'.' '{print $1}')
|
||||
IH=$(echo "scale=${DIGITS};${IW}*${R}" | bc | awk -F'.' '{print $1}')
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
convert -size ${OW}x${OH} -colorspace sRGB xc:#FFFFFF "${TMP}/white.png"
|
||||
convert "${2}" -resize ${IW}x${IH} "${TMP}/resize.tif"
|
||||
composite -gravity Center -colorspace sRGB "${TMP}/resize.tif" "${TMP}/white.png" "${3}"
|
||||
convert -size ${OW}x${OH} -colorspace sRGB xc:#FFFFFF "${TMP}/white.tif"
|
||||
convert "${3}" -resize ${IW}x${IH} "${TMP}/resize.tif"
|
||||
composite -gravity Center -colorspace sRGB "${TMP}/resize.tif" "${TMP}/white.tif" "${4}"
|
||||
rm -rf "${TMP}"
|
||||
|
||||
echo "Centered in white ${2} -> ${3}"
|
||||
echo "Centered in white ${3} -> ${4}"
|
Loading…
Reference in New Issue