The jpeginfo
command-line tool is a handy utility for analyzing and checking JPEG files. Whether you're verifying image integrity, checking for corruption, or automating image inspections in scripts, jpeginfo
can help. Here are five different ways you can use it:
1. Check for Corrupt JPEG Files
You can quickly scan a directory for corrupt JPEG files using:
jpeginfo -c *.jpg
This command checks the integrity of each file and reports if it's "OK" or "BROKEN". Very useful for validating large image libraries.
2. Get Basic Info About JPEG Files
To view basic information like image resolution and quality factor:
jpeginfo *.jpg
This displays width, height, and compression details for each JPEG image.
3. Recursively Check JPEGs in Subdirectories
Use find
with jpeginfo
to scan images in subfolders:
find . -name "*.jpg" -exec jpeginfo -c {} \;
This is ideal for large projects where images are stored in nested directories.
4. Filter Only Broken JPEGs
If you want to list only the broken JPEG files, you can combine jpeginfo
with grep
:
jpeginfo -c *.jpg | grep -i "BROKEN"
This helps in isolating corrupt files for deletion or recovery.
5. Use in Batch Scripts for Automation
You can incorporate jpeginfo
into shell scripts to automate image validation tasks:
#!/bin/bash
for img in *.jpg; do
if ! jpeginfo -c "$img" | grep -q "OK"; then
echo "Corrupt file detected: $img"
fi
done
This script checks each JPEG in a folder and logs the name of corrupt files.
Conclusion
jpeginfo
is a simple yet powerful tool for anyone working with JPEG files. From quick integrity checks to scripting automation, it helps ensure your images are clean and usable.
No comments:
Post a Comment