Skip to content

Instantly share code, notes, and snippets.

@renanyoy
Created March 3, 2026 02:50
Show Gist options
  • Select an option

  • Save renanyoy/98c915c526bfd97e9ae0214c2b44af74 to your computer and use it in GitHub Desktop.

Select an option

Save renanyoy/98c915c526bfd97e9ae0214c2b44af74 to your computer and use it in GitHub Desktop.
verify jpeg (needs imagemagick)
function fixwrongjpeg() {
find . -name "*.jpg" | while IFS= read -r file; do
mime=$(file --mime-type -b "$file")
if [[ $mime != image/jpeg ]]; then
mv "$file" "$file.wrong"
convert "$file.wrong" "$file"
echo "fixed $file"
rm "$file.wrong"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment