Update preprocess_png_sticoeureuse.sh

This commit is contained in:
jo 2024-12-12 13:52:08 +00:00
parent ba2d06701d
commit 000ab55426

View file

@ -53,8 +53,6 @@ while getopts 'i:o:sW:Narfh' flag; do
esac
done
echo ${input}
if [ "${all}" = "true" ]; then
find_all() {
first=1
@ -79,7 +77,7 @@ if [ "${all}" = "true" ]; then
cd ${input}
fi
all=$(find_all "jpg" "jpeg" "png" "pdf" "PNG" "JPG")
all=$(find_all "jpg" "jpeg" "png" "pdf" "PNG" "JPG" "PDF")
OIFS="$IFS"
IFS=$'\n'
for file in $all; do
@ -89,11 +87,26 @@ if [ "${all}" = "true" ]; then
continue
fi
if [[ "${file##*.}" = "pdf" || "${file##*.}" = "PDF" ]] ; then
rm_file=true
old_file=$file
base_file_name=$(basename "${file%.*}")
file=".tmp_${base_file_name}.png"
magick $old_file $file
fi
if [ "$(( $(identify -format "%w ${turn} %h" ${file}) ))" = "1" ]; then
ffmpeg -i ${file} -frames:v 1 -vf scale=-1:719:force_original_aspect_ratio=decrease,curves=m="${curve}",hue=s=0,format=monob -pix_fmt rgb32 ${output} -y
else
ffmpeg -i ${file} -frames:v 1 -vf scale=719:-1:force_original_aspect_ratio=decrease,curves=m="${curve}",hue=s=0,format=monob,transpose=1 -pix_fmt rgb32 ${output} -y
fi
if [ $rm_file == true ]; then
rm_file=false
rm ${file}
fi
done
IFS=$OIFS
else
@ -106,9 +119,24 @@ else
output="${input%.*}_preprocessed.png"
fi
if [[ "${input##*.}" = "pdf" || "${input##*.}" = "PDF" ]] ; then
rm_file=true
old_file=$input
base_file_name=$(basename "${input%.*}")
input=".tmp_${base_file_name}.png"
magick $old_file $input
fi
if [ "$(( $(identify -format "%w ${turn} %h" ${input}) ))" = "1" ]; then
ffmpeg -i ${input} -frames:v 1 -vf scale=-1:719:force_original_aspect_ratio=decrease,curves=m="${curve}",hue=s=0,format=monob -pix_fmt rgb32 ${output} -y
else
ffmpeg -i ${input} -frames:v 1 -vf scale=719:-1:force_original_aspect_ratio=decrease,curves=m="${curve}",hue=s=0,format=monob,transpose=1 -pix_fmt rgb32 ${output} -y
fi
if [ $rm_file == true ]; then
rm_file=false
rm ${input}
fi
fi