↑ ↓ select, Enter open, Esc close

Remove EXIF and other metadata from images

Adjust the values, the command updates live
user@server
exiftool -r -ext jpg -ext jpeg -all= -overwrite_original /var/www/vhosts/example.com/httpdocs/wp-content/uploads

Recursively deletes all metadata from every JPEG and overwrites the files in place. This saves a few kilobytes per image and prevents the location or camera details from being publicly accessible. The image data itself stays unchanged.

Note: Copyright notices and color profiles are removed as well. To remove only GPS data, use -gps:all= instead of -all=. Package libimage-exiftool-perl.

Also searched as

  • remove exif data from images linux
  • strip gps coordinates from photos
  • remove image metadata command line
  • exiftool remove all metadata recursively

Find images containing GPS coordinates

$exiftool -r -ext jpg -ext jpeg -if '$gpslatitude' -p '$directory/$filename' /var/www/vhosts/example.com/httpdocs/wp-content/uploads 2>/dev/null
harmlessImages and performance

Convert images to AVIF recursively

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.avif" ] || avifenc -s 6 "$f" "$f.avif" >/dev/null; done' sh {} +
cautionImages and performance

Convert images to WebP recursively

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.webp" ] || cwebp -quiet -q 80 "$f" -o "$f.webp"; done' sh {} +
cautionImages and performance

Find images larger than a given pixel size

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec identify -format '%w %h %i\n' {} + 2>/dev/null | awk -v max=2560 '$1 > max || $2 > max'
harmlessImages and performance

Find images without a loading attribute on a page

$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -vi 'loading='
harmlessImages and performance

Find large images in wp-content/uploads

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.webp' \) -size +500k -printf '%s\t%p\n' | sort -rn | head -50 | numfmt --field=1 --to=iec
harmlessImages and performance

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.