¿Cómo puedo leer y eliminar metadatos (exif) de mis fotos usando la línea de comando?


Respuestas:


79

Instalar exiftool:

sudo apt-get install libimage-exiftool-perl

Para leer metadatos de fotos:

exiftool /tmp/my_photo.jpg

Para borrar metadatos de fotos:

exiftool -all= /tmp/my_photo.jpg

Antes de:

ExifTool Version Number         : 8.60
File Name                       : my_photo.jpg
Directory                       : /tmp
File Size                       : 3.0 MB
File Modification Date/Time     : 2013:02:24 12:08:10-08:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Orientation                     : Unknown (0)
Y Cb Cr Positioning             : Centered
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Modify Date                     : 2013:02:24 11:25:27
Make                            : Samsung
Camera Model Name               : Galaxy Nexus
Exif Version                    : 0220
Flashpix Version                : 
Color Space                     : sRGB
Components Configuration        : Y, Cb, Cr, -
Compressed Bits Per Pixel       : 0
Exif Image Width                : 1944
Exif Image Height               : 2592
Date/Time Original              : 2013:02:24 11:25:27
Create Date                     : 2013:02:24 11:25:27
Exposure Time                   : 1/354
F Number                        : 2.8
Exposure Program                : Aperture-priority AE
ISO                             : 50, 0, 0
Shutter Speed Value             : 1/353
Aperture Value                  : 2.6
Brightness Value                : 0
Exposure Compensation           : 0
Max Aperture Value              : 2.6
Subject Distance                : 0 m
Metering Mode                   : Multi-spot
Light Source                    : Daylight
Flash                           : No Flash
Focal Length                    : 3.4 mm
Flash Energy                    : 0
Exposure Index                  : undef
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Custom Rendered                 : Custom
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 1
Scene Capture Type              : Standard
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Subject Distance Range          : Unknown
Image Unique ID                 : OAEL01
GPS Time Stamp                  : 19:25:27
GPS Date Stamp                  : 2013:02:24
Compression                     : JPEG (old-style)
Thumbnail Offset                : 2143
Thumbnail Length                : 10941
Image Width                     : 1944
Image Height                    : 2592
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 2.8
GPS Date/Time                   : 2013:02:24 19:25:27Z
Image Size                      : 1944x2592
Shutter Speed                   : 1/354
Thumbnail Image                 : (Binary data 10941 bytes, use -b option to extract)
Focal Length                    : 3.4 mm
Light Value                     : 12.4

Después:

ExifTool Version Number         : 8.60
File Name                       : my_photo.jpg
Directory                       : /tmp
File Size                       : 2.9 MB
File Modification Date/Time     : 2013:02:24 12:21:39-08:00
File Permissions                : rw-rw-r--
File Type                       : JPEG
MIME Type                       : image/jpeg
Image Width                     : 1944
Image Height                    : 2592
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 1944x2592

Referencias


1
Para procesar todos los archivos en el directorio actual: for f in *.jpg; do exiftool -all= "$f"; done
twobeers

66
o simplementeexiftool *.jpg
gavenkoa

15

Imagemagick

En lugar de Exiftool , para manejar los metadatos Exif encontré más útil y el comando más fácil de recordar usando Imagemagick :

Leer

identify -verbose image.jpg | grep exif

Para eliminar

Con el imagemagickpaquete instalado, puede hacer esto ( no solo para archivos JPEG ):

mogrify -strip *.jpg

Del manual :

-tira

pele la imagen de cualquier perfil, comentario o estos fragmentos PNG: bKGD, cHRM, EXIF, gAMA, iCCP, iTXt, sRGB, tEXt, zCCP, zTXt, date.

AFAIK la única diferencia es que mogrifyno eliminará estos metadatos:

  • Versión JFIF
  • Unidad de resolución
  • X resolución
  • Resolución Y

Lo que puede ser útil. Comparado condiff -y <(exiftool wMogrify.jpg) <(exiftool wExiftool.jpg)

Eliminar datos EXIF! = Anonimizar : -stripvolverá a comprimir la imagen . Esto podría ser algo bueno : el mismo software que toma la foto podría ocultar datos en la imagen ( esteganografía ). No estoy seguro de si la recompresión siempre eliminará todo (probablemente no). Para evitar esta recompresión, puede usar jpegtran :

jpegtran -copy none image.jpg > newimage.jpg

Además, para evitar perder el perfil de color ( ICC , que causa colores más ricos [cita requerida] ):

convert image.jpg profile.icm && convert image.jpg -strip -profile profile.icm newimage.jpg

Puede preguntarse si estos costos son notables o relevantes en su caso.

Otra herramienta sobre esteganografía en imágenes es la steghide .


Ver también



1
@CiroSantilli 新疆 改造 中心 996ICU 六四 事件 Edité la respuesta. Eso 'podría ser algo bueno, eliminar los metadatos codificados en la imagen. Sería genial tener estudios para apoyar esto.
Pablo A

Sí, lo noté porque el tamaño de la imagen había cambiado considerablemente, pero debe haber mejores formas, al menos en 2010 los desarrolladores de ImageMagick lo confirmaron: stackoverflow.com/questions/2654281/…
Ciro Santilli i 改造 中心 法轮功 六四 事件

6

Para eliminar y luego cambiar un solo campo, podemos usar este comando:

exiftool -Copyright= IMG_3357.jpg
exiftool -Copyright=LinuxSlaves IMG_3357.jpg

Referencia

Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.