extrai a miniatura da imagem CR2 usando o exiftool

3

Eu estou tentando extrair uma imagem em miniatura JPEG de uma imagem CR2, usando exiftool , no Windows.

Eu obtive sucesso usando este programa, QuickJPGFromCR2. A partir da descrição, parece extrair a visualização JPEG dos dados EXIF. O arquivo resultante tem a mesma largura e altura da imagem original e está entre 1 ~ 2 MB para os arquivos com os quais estou trabalhando.

Em primeiro lugar, a saída de exiftool .\Kendall_FACS_0002_0100A.cr2 é a seguinte:

ExifTool Version Number         : 10.45
File Name                       : Kendall_FACS_0002_0100A.cr2
Directory                       : .
File Size                       : 25 MB
File Modification Date/Time     : 2016:10:20 14:47:47-05:00
File Access Date/Time           : 2016:11:21 18:26:10-06:00
File Creation Date/Time         : 2017:01:23 14:14:05-06:00
File Permissions                : rw-rw-rw-
File Type                       : CR2
File Type Extension             : cr2
MIME Type                       : image/x-canon-cr2
Exif Byte Order                 : Little-endian (Intel, II)
Image Width                     : 5184
Image Height                    : 3456
Bits Per Sample                 : 8 8 8
Compression                     : JPEG (old-style)
Make                            : Canon
Camera Model Name               : Canon EOS REBEL T3i
Preview Image Start             : 68120
Orientation                     : Horizontal (normal)
Preview Image Length            : 1708300
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Modify Date                     : 2016:10:20 14:46:19
Artist                          : 
Rating                          : 0
Copyright                       : 
Exposure Time                   : 1/100
F Number                        : 16.0
Exposure Program                : Manual
ISO                             : 100
Sensitivity Type                : Recommended Exposure Index
Recommended Exposure Index      : 100
Exif Version                    : 0230
Date/Time Original              : 2016:10:20 14:46:19
Create Date                     : 2016:10:20 14:46:19
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/99
Aperture Value                  : 16.0
Flash                           : Off, Did not fire
Focal Length                    : 40.0 mm
Macro Mode                      : Normal
Self Timer                      : Off
Quality                         : RAW
Canon Flash Mode                : Off
Continuous Drive                : Single
Focus Mode                      : Manual Focus (3)
Record Mode                     : CR2
Canon Image Size                : n/a
Easy Mode                       : Manual
Digital Zoom                    : None
Contrast                        : Normal
Saturation                      : Normal
Metering Mode                   : Evaluative
Focus Range                     : Not Known
Canon Exposure Mode             : Manual
Lens Type                       : Canon EF 40mm f/2.8 STM
Max Focal Length                : 40 mm
Min Focal Length                : 40 mm
Focal Units                     : 1/mm
Max Aperture                    : 2.8
Min Aperture                    : 23
Flash Activity                  : 0
Flash Bits                      : (none)
Zoom Source Width               : 0
Zoom Target Width               : 0
Manual Flash Output             : n/a
Color Tone                      : Normal
SRAW Quality                    : n/a
Auto ISO                        : 100
Base ISO                        : 100
Measured EV                     : 6.00
Target Aperture                 : 16
Target Exposure Time            : 1/102
Exposure Compensation           : 0
White Balance                   : Daylight
Slow Shutter                    : None
Shot Number In Continuous Burst : 0
Optical Zoom Code               : n/a
Camera Temperature              : 30 C
Flash Guide Number              : 0
Flash Exposure Compensation     : 0
Auto Exposure Bracketing        : Off
AEB Bracket Value               : 0
Control Mode                    : Camera Local Control
Measured EV 2                   : 6.625
Bulb Duration                   : 0
Camera Type                     : EOS High-end
ND Filter                       : n/a
Canon Image Type                : Canon EOS REBEL T3i
Canon Firmware Version          : Firmware Version 1.0.2
Flash Metering Mode             : Off
Camera Orientation              : Horizontal (normal)
Firmware Version                : 1.0.2
File Index                      : 2
Directory Index                 : 100
Contrast Standard               : 0
Sharpness Standard              : 3
Saturation Standard             : 0
Color Tone Standard             : 0
Contrast Portrait               : 0
Sharpness Portrait              : 2
Saturation Portrait             : 0
Color Tone Portrait             : 0
Contrast Landscape              : 0
Sharpness Landscape             : 4
Saturation Landscape            : 0
Color Tone Landscape            : 0
Contrast Neutral                : 0
Sharpness Neutral               : 0
Saturation Neutral              : 0
Color Tone Neutral              : 0
Contrast Faithful               : 0
Sharpness Faithful              : 0
Saturation Faithful             : 0
Color Tone Faithful             : 0
Contrast Monochrome             : 0
Sharpness Monochrome            : 3
Filter Effect Monochrome        : None
Toning Effect Monochrome        : None
Contrast Auto                   : 0
Sharpness Auto                  : 3
Saturation Auto                 : 0
Color Tone Auto                 : 0
Filter Effect Auto              : n/a
Toning Effect Auto              : n/a
Contrast User Def 1             : 0
Sharpness User Def 1            : 3
Saturation User Def 1           : 0
Color Tone User Def 1           : 0
Filter Effect User Def 1        : None
Toning Effect User Def 1        : None
Contrast User Def 2             : 0
Sharpness User Def 2            : 3
Saturation User Def 2           : 0
Color Tone User Def 2           : 0
Filter Effect User Def 2        : None
Toning Effect User Def 2        : None
Contrast User Def 3             : 0
Sharpness User Def 3            : 3
Saturation User Def 3           : 0
Color Tone User Def 3           : 0
Filter Effect User Def 3        : None
Toning Effect User Def 3        : None
User Def 1 Picture Style        : Auto
User Def 2 Picture Style        : Auto
User Def 3 Picture Style        : Auto
Canon Model ID                  : EOS Rebel T3i / 600D / Kiss X5
Thumbnail Image Valid Area      : 0 159 7 112
AF Area Mode                    : Off (Manual Focus)
Num AF Points                   : 9
Valid AF Points                 : 9
Canon Image Width               : 5184
Canon Image Height              : 3456
AF Image Width                  : 5184
AF Image Height                 : 3456
AF Area Widths                  : 139 139 139 196 238 196 139 139 139
AF Area Heights                 : 186 186 186 127 231 127 186 186 186
AF Area X Positions             : -1477 -886 -886 0 0 0 886 886 1477
AF Area Y Positions             : 0 418 -418 787 0 -787 418 -418 0
AF Points In Focus              : (none)
AF Points Selected              : 0,1,2,3,4,5,6,7,8
Original Decision Data Offset   : 0
Bracket Mode                    : Off
Bracket Value                   : 0
Bracket Shot Number             : 0
Raw Jpg Size                    : Large
Long Exposure Noise Reduction 2 : Off
WB Bracket Mode                 : Off
WB Bracket Value AB             : 0
WB Bracket Value GM             : 0
Live View Shooting              : Off
Focus Distance Upper            : 2.16 m
Focus Distance Lower            : 1.46 m
Flash Exposure Lock             : Off
Internal Serial Number          : ZC1954285
Dust Removal Data               : (Binary data 1024 bytes, use -b option to extract)
Crop Left Margin                : 0
Crop Right Margin               : 0
Crop Top Margin                 : 0
Crop Bottom Margin              : 0
Exposure Level Increments       : 1/3 Stop
ISO Expansion                   : Off
Flash Sync Speed Av             : Auto
Long Exposure Noise Reduction   : Off
High ISO Noise Reduction        : Standard
Highlight Tone Priority         : Disable
AF Assist Beam                  : Does not emit
Mirror Lockup                   : Enable
Shutter-AE Lock                 : AF/AE lock
Set Button When Shooting        : Normal (disabled)
LCD Display At Power On         : Display
Add Original Decision Data      : Off
Aspect Ratio                    : 3:2
Cropped Image Width             : 5184
Cropped Image Height            : 3456
Cropped Image Left              : 0
Cropped Image Top               : 0
Tone Curve                      : Standard
Sharpness                       : 3
Sharpness Frequency             : n/a
Sensor Red Level                : 0
Sensor Blue Level               : 0
White Balance Red               : 0
White Balance Blue              : 0
Color Temperature               : 5200
Picture Style                   : Auto
Digital Gain                    : 0
WB Shift AB                     : 0
WB Shift GM                     : 0
Measured RGGB                   : 431 1024 1024 768
VRD Offset                      : 0
Sensor Width                    : 5344
Sensor Height                   : 3516
Sensor Left Border              : 152
Sensor Top Border               : 56
Sensor Right Border             : 5335
Sensor Bottom Border            : 3511
Black Mask Left Border          : 0
Black Mask Top Border           : 0
Black Mask Right Border         : 0
Black Mask Bottom Border        : 0
Color Data Version              : 10 (600D/1200D)
WB RGGB Levels As Shot          : 2123 1024 1024 1556
Color Temp As Shot              : 5200
WB RGGB Levels Auto             : 2028 1024 1024 1606
Color Temp Auto                 : 4908
WB RGGB Levels Measured         : 2028 1024 1024 1606
Color Temp Measured             : 4908
WB RGGB Levels Daylight         : 2123 1024 1024 1556
Color Temp Daylight             : 5200
WB RGGB Levels Shade            : 2439 1024 1024 1321
Color Temp Shade                : 7000
WB RGGB Levels Cloudy           : 2280 1024 1024 1431
Color Temp Cloudy               : 6000
WB RGGB Levels Tungsten         : 1540 1024 1024 2341
Color Temp Tungsten             : 3200
WB RGGB Levels Fluorescent      : 1869 1024 1024 2226
Color Temp Fluorescent          : 3729
WB RGGB Levels Kelvin           : 2123 1024 1024 1556
Color Temp Kelvin               : 5200
WB RGGB Levels Flash            : 2367 1024 1024 1411
Color Temp Flash                : 6303
Average Black Level             : 2048 2048 2048 2048
Raw Measured RGGB               : 99047 229396 224807 170653
Per Channel Black Level         : 2047 2047 2048 2048
Normal White Level              : 11767
Specular White Level            : 12279
Linearity Upper Margin          : 10000
Picture Style User Def          : Auto; Auto; Auto
Picture Style PC                : None; None; None
Custom Picture Style File Name  : 
Vignetting Corr Version         : 0
Peripheral Lighting             : Off
Chromatic Aberration Corr       : Off
Peripheral Lighting Value       : 0
Original Image Width            : 5184
Original Image Height           : 3456
Peripheral Lighting Setting     : Off
Peripheral Illumination Corr    : Off
Auto Lighting Optimizer         : Off
User Comment                    : 
Sub Sec Time                    : 46
Sub Sec Time Original           : 46
Sub Sec Time Digitized          : 46
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 5184
Exif Image Height               : 3456
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Focal Plane X Resolution        : 5728.176796
Focal Plane Y Resolution        : 5808.403361
Focal Plane Resolution Unit     : inches
Custom Rendered                 : Normal
Exposure Mode                   : Manual
Scene Capture Type              : Standard
Owner Name                      : CAM1100A1
Serial Number                   : 252076117630
Lens Info                       : 40mm f/?
Lens Model                      : EF40mm f/2.8 STM
Lens Serial Number              : 00002bc0be
Thumbnail Offset                : 55048
Thumbnail Length                : 13072
Photometric Interpretation      : RGB
Samples Per Pixel               : 3
Rows Per Strip                  : 432
Planar Configuration            : Chunky
Strip Offsets                   : 3513124
Strip Byte Counts               : 22248252
Raw Image Segmentation          : 2 1728 1888
SRaw Type                       : 1
Aperture                        : 16.0
Drive Mode                      : Single-frame Shooting
File Number                     : 100-0002
Image Size                      : 5184x3456
Lens                            : 40.0 mm
Lens ID                         : Canon EF 40mm f/2.8 STM
Megapixels                      : 17.9
Preview Image                   : (Binary data 1708300 bytes, use -b option to extract)
Scale Factor To 35 mm Equivalent: 1.6
Shooting Mode                   : Manual
Shutter Speed                   : 1/100
Create Date                     : 2016:10:20 14:46:19.46
Date/Time Original              : 2016:10:20 14:46:19.46
Modify Date                     : 2016:10:20 14:46:19.46
Thumbnail Image                 : (Binary data 13072 bytes, use -b option to extract)
WB RGGB Levels                  : 2123 1024 1024 1556
Blue Balance                    : 1.519531
Circle Of Confusion             : 0.019 mm
Depth Of Field                  : 1.38 m (1.35 - 2.73 m)
Field Of View                   : 31.9 deg
Focal Length                    : 40.0 mm (35 mm equivalent: 62.9 mm)
Hyperfocal Distance             : 5.23 m
Lens                            : 40.0 mm (35 mm equivalent: 62.9 mm)
Light Value                     : 14.6
Red Balance                     : 2.073242

Então, olhando para os campos de dados binários (aqueles que sugerem a extração usando a opção -b ), obtemos:

Dust Removal Data               : (Binary data 1024 bytes, use -b option to extract)
Preview Image                   : (Binary data 1708300 bytes, use -b option to extract)
Thumbnail Image                 : (Binary data 13072 bytes, use -b option to extract)

A tag Preview Image parece ser o que estamos procurando, mas o Thumbnail Image também é intrigante (embora bem pequeno).

Execução dos seguintes comandos:

exiftool -b .\Kendall_FACS_0002_0100A.cr2 > out.jpg
exiftool -b -PreviewImage .\Kendall_FACS_0002_0100A.cr2 > out.jpg
exiftool -b -ThumbnailImage .\Kendall_FACS_0002_0100A.cr2 > out.jpg

Os dois primeiros comandos resultam em arquivos 3,28 MB grandes, enquanto o último é apenas 25,6 KB. Todos não conseguem abrir em nenhum programa. O Windows Photo Viewer diz que não é possível abrir o arquivo porque the file appears to be damaged, corrputed, or is too large .

O comando identify do ImageMagick fornece a seguinte saída para a tag Preview Image :

exiftool -b -PreviewImage .\Kendall_FACS_0002_0100A.cr2 | identify -
identify.exe: no decode delegate for this image format '' @ error/constitute.c/ReadImage/504.

exiftool -b -PreviewImage .\Kendall_FACS_0002_0100A.cr2 | identify jpg:-
identify.exe: Not a JPEG file: starts with 0x3f 0x3f '-' @ error/jpeg.c/JPEGErrorHandler/322.

Eu notei em outro lugar na internet pessoas usando a opção -JpegFromRaw , mas meus dados EXIF não possuem essa tag.

Então, o que diabos eu estou fazendo errado?

    
por John T 06.03.2017 / 23:44

1 resposta

4

No primeiro comando, você está extraindo todos os metadados brutos e salvando-os em out.jpg. Isso cria um arquivo de lixo que não é uma imagem. O segundo e terceiro comando deve funcionar e eles fazem na amostra .cr2 que eu tenho. O PreviewImage é um jpg embutido que deve ser o mesmo que o jpg criado se sua câmera foi configurada para salvar Jpgs + Raw. O ThumbnailImage é um jpg muito pequeno (160x120 no exemplo que tenho) que pode ser usado por alguns programas como uma imagem em miniatura para acelerar a navegação da imagem.

A opção JpegFromRaw é usada para extrair visualizações de algumas câmeras antigas, e provavelmente não fará nada pela sua câmera.

Qual versão do exiftool você está usando (digite exiftool -ver )?

Tanto exiftool -b -PreviewImage .\Kendall_FACS_0002_0100A.cr2 > out.jpg como exiftool -b -ThumbnailImage .\Kendall_FACS_0002_0100A.cr2 > out.jpg devem funcionar.

Editar: Após alguns testes entre nós, parece que o PowerShell está assumindo que a saída do exiftool é ASCII e está convertendo-a em Unicode, corrompendo a saída.

Páginas da Internet relacionadas com isto: link link

Em conclusão, não havia nada de errado com os comandos em si, mas sim com a manipulação de dados binários brutos pelo Powershell. Executar os comandos no CMD resulta na saída esperada.

    
por 07.03.2017 / 01:46