Detecting blank (no pixel) image files - version 7.0.8 Q16
Posted: 2018-10-15T04:18:19-07:00
Hi everyone,
I've seen several topics about approching subject. But I can't find the solution by myself.
I'm very new to shell and coding in general.
My goal is to detect blank image files in a given folder and delete those files.
Here's what I have so far (found in the forum) :
This seems to return my blank image files (is it correct ?). The topic where I found this piece of code said that this is suppose to find white images.
Say I found how to detect my blank images, I don't know how to use the returned value found in the convert function.
Any help is welcome !
EDIT
I also found this solution :
I do get the logic, but the langage is too cryptic for me. Here it gives me this error:
I "understand" what it means, but I don't know how to correct it.
Thanks
Arko
I've seen several topics about approching subject. But I can't find the solution by myself.
I'm very new to shell and coding in general.
My goal is to detect blank image files in a given folder and delete those files.
Here's what I have so far (found in the forum) :
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:
done
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:
if [ ??? = "0" ]; then
echo "$file seems to be blank - removing it..."
rm "$file"
fi
done
Any help is welcome !
EDIT
I also found this solution :
Code: Select all
for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
histogram=`convert "$file" -threshold 50% -format %c histogram:info:-`
white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
if [ "${blank}" == "1" ]; then
echo "$file seems to be blank - removing it..."
rm "$file"
fi
done
Code: Select all
bash: bc: command not found
Thanks
Arko