Sort images by resolution
When recovery of files done and you restored images with help of a post recovery tasks script then it could be wise to sort images by the resolution. This will help to sort the photos you made, webcam images or any other images into the folders by the resolutions, most of them are often using the same related image resolutions.
Collect info about images
collect-info-about-images.sh
#!/bin/bash if [ 'XX' != 'XX'"$1" ]; then if [ -f "$1" ]; then # mime part start IsIt=$(file "$1" --mime-type -b); NeedImageOnly="ItIs_"${IsIt/'/'*/} if [ "$NeedImageOnly" == "ItIs_image" ] ; then # mime part end ImageInfoFEH=($(feh -l "$1")) IfDamaged=${?} ImageType=${ImageInfoFEH[9]} Height=${ImageInfoFEH[11]} Width=${ImageInfoFEH[10]} if [ "$IfDamaged" != '0' ]; then echo "$1" "Damaged" "${IfDamaged}"; fi; echo "$1"'|'W'|'$Width'|'H'|'$Height'|'Format'|'$ImageType'|'Errors'|'$IfDamaged'|' >> collect-info-about-images.txt # mime part start fi # mime part end else echo The « "$1" » is not a valid file name. fi else ScriptsName=${0##*/} find -type f -exec sh -e "./$ScriptsName" "{}" \; #find -type f -name "*.jpg" -o -name "*.gif" -o -name "*.png" -exec sh -e "./$ScriptsName" "{}" \; fi
The $IfDamaged variable contains an exit status code returned by feh.
You can also install to check integrity of "PNG, JNG or MNG" and/or jpeginfoAUR and use output of errors in the $IfDamaged variable or modify script to skip adding of damaged files into a collect-info-about-images.txt
file.
Example of check resuslt:
Example of jpeginfoAUR check result:
find -type f -name "*.jpg">>FileWithPathTo-images.txt
, calculate their md5sums and has an option that makes it able to remove damaged image files.To extract necessary data from a string in a script is better to use an expression instead of an extern program as sed or to make a script work a little faster, e.g.
The collect-info-about-images.sh script generates data about images by pattern:
full path to image|Width|size|Height|size|Format|type of image|Errors|exit code by feh|
Example:
Sort images by resolution
This script creates folders based on the resolution. You can set your limitations about how many files should be in each folder and how many sub-directories in a base file type named folder. When limit is reached a new number in the order will be added to a directory name for creation. If you have a really huge amount of files and do not want to overload a single folder with all of them then you can also add your own counters for a new sub-folders after the base destination variable , just look out for quotes " to be in the begin and end of a whole destination path. It use to be much more easier to browse folders with a limited amount of images, thumbnails loads much faster and to remember or add to favorite a folder number/name instead of trying to find once more same image in an overloaded folder out of probably thousand images there.