Update preprocess_png_sticoeureuse.sh
This commit is contained in:
parent
ba2d06701d
commit
000ab55426
1 changed files with 31 additions and 3 deletions
|
@ -53,8 +53,6 @@ while getopts 'i:o:sW:Narfh' flag; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ${input}
|
|
||||||
|
|
||||||
if [ "${all}" = "true" ]; then
|
if [ "${all}" = "true" ]; then
|
||||||
find_all() {
|
find_all() {
|
||||||
first=1
|
first=1
|
||||||
|
@ -79,7 +77,7 @@ if [ "${all}" = "true" ]; then
|
||||||
cd ${input}
|
cd ${input}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
all=$(find_all "jpg" "jpeg" "png" "pdf" "PNG" "JPG")
|
all=$(find_all "jpg" "jpeg" "png" "pdf" "PNG" "JPG" "PDF")
|
||||||
OIFS="$IFS"
|
OIFS="$IFS"
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for file in $all; do
|
for file in $all; do
|
||||||
|
@ -89,11 +87,26 @@ if [ "${all}" = "true" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
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
|
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
|
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
|
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
|
fi
|
||||||
|
|
||||||
|
if [ $rm_file == true ]; then
|
||||||
|
rm_file=false
|
||||||
|
rm ${file}
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OIFS
|
IFS=$OIFS
|
||||||
else
|
else
|
||||||
|
@ -106,9 +119,24 @@ else
|
||||||
output="${input%.*}_preprocessed.png"
|
output="${input%.*}_preprocessed.png"
|
||||||
fi
|
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
|
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
|
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
|
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
|
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
|
fi
|
||||||
|
|
||||||
|
if [ $rm_file == true ]; then
|
||||||
|
rm_file=false
|
||||||
|
rm ${input}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue