ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Tobias on September 30, 2012, 10:12:46 AM

Title: Unable to extract/delete JPEG preview image
Post by: Tobias on September 30, 2012, 10:12:46 AM
Hi,

I do have problems extracting (and/or removing) preview images from JPEGs shot with my Sony SLT-A55.
Running exiftool -PreviewImage= DSC00000.JPG will output "1 image files updated", but the filesize is only reduced by about 4 KB although the preview image size is a couple of 100 KB.
Accordingly exiftool -g DSC00000_no_preview.JPG will output the following afterwards: Preview Image                   : (Binary data 414410 bytes, use -b option to extract)
Running exiftool -b -PreviewImage DSC00000.JPG > preview.jpg on the untouched JPEG will result in "Warning: [minor] Error reading PreviewImage - DSC00000.JPG" and an empty preview.jpg file.

I don't know if it's in any way related, but the SLT-A55 is writing quite a large amount of garbage FF bytes to the JPEGs (see this discussion on dpreview.com (http://forums.dpreview.com/forums/read.asp?forum=1037&message=37784962&changemode=1)). Maybe this is corrupting the files in some form?

Attached you can find a sample file.

Any help is appreciated!
Tobias
Title: Re: Unable to extract/delete JPEG preview image
Post by: Phil Harvey on September 30, 2012, 12:55:00 PM
Hi Tobias,

I will have to look into why -previewimage= doesn't work, but using -trailer:all= will do what you want because the PreviewImage is stored in the trailer of A55 JPEG's.

- Phil
Title: Re: Unable to extract/delete JPEG preview image
Post by: Phil Harvey on September 30, 2012, 01:05:35 PM
I just looked into this, and exiftool 9.02 doesn't have any problem deleting the preview from my sample SLT-A55V JPEG:

> Image-ExifTool-9.02/exiftool a.jpg -model -filesize# -previewimage
Camera Model Name               : SLT-A55V
File Size                       : 5046272
Preview Image                   : (Binary data 630216 bytes, use -b option to extract)

> Image-ExifTool-9.02/exiftool a.jpg -previewimage=
    1 image files updated

> Image-ExifTool-9.02/exiftool a.jpg -filesize# -previewimage -f
File Size                       : 4125934
Previewimage                    : -


What version of ExifTool are you using?

- Phil
Title: Re: Unable to extract/delete JPEG preview image
Post by: Tobias on September 30, 2012, 01:29:47 PM
Hi Phil,

Thanks for your help! I'm using the Windows version of ExifTool 9.02. It's really strange it worked for you.

The option you suggested doesn't work for me as well:

>exiftool -v -v -v -trailer:all= DSC00128.JPG
  Deleting tags in: Trailer
======== DSC00128.JPG
Rewriting DSC00128.JPG...
  Editing tags in: Trailer
  Creating tags in:
JPEG APP1 (64506 bytes):
    0000: 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 0d 00 [Exif..II*.......]
    0010: 0e 01 02 00 20 00 00 00 aa 00 00 00 0f 01 02 00 [.... ...........]
    0020: 05 00 00 00 ca 00 00 00 10 01 02 00 09 00 00 00 [................]
    0030: d0 00 00 00 12 01 03 00 01 00 00 00 01 00 00 00 [................]
    0040: 1a 01 05 00 01 00 00 00 da 00 00 00 1b 01 05 00 [................]
    0050: 01 00 00 00 e2 00 00 00 28 01 03 00 01 00 00 00 [........(.......]
    0060: 02 00 00 00 31 01 02 00 0f 00 00 00 ea 00 00 00 [....1...........]
    [snip 64394 bytes]
JPEG APP2 (86 bytes):
    0000: 4d 50 46 00 49 49 2a 00 08 00 00 00 03 00 00 b0 [MPF.II*.........]
    0010: 07 00 04 00 00 00 30 31 30 30 01 b0 04 00 01 00 [......0100......]
    0020: 00 00 02 00 00 00 02 b0 07 00 20 00 00 00 32 00 [.......... ...2.]
    0030: 00 00 00 00 00 00 00 00 03 a0 2e e1 33 00 00 00 [............3...]
    0040: 00 00 02 00 00 00 02 00 01 40 ca 52 06 00 f8 03 [.........@.R....]
    0050: 36 00 00 00 00 00                               [6.....]
JPEG DQT (130 bytes):
JPEG DHT (416 bytes):
JPEG SOF0:
JPEG SOS
Nothing changed in DSC00128.JPG
    0 image files updated
    1 image files unchanged


I have tried what you did and this is the output I got:

>exiftool DSC00128.JPG -model -filesize# -previewimage
Camera Model Name               : SLT-A55V
File Size                       : 3399982

>exiftool DSC00128.JPG -previewimage=
    1 image files updated

>exiftool DSC00128.JPG -filesize# -previewimage -f
File Size                       : 3396308
Previewimage                    : -

>exiftool -ee -warning -exiftoolversion DSC00128.JPG
Warning                         : [minor] Error reading PreviewImage from file
ExifTool Version Number         : 9.02
Title: Re: Unable to extract/delete JPEG preview image
Post by: Phil Harvey on September 30, 2012, 08:08:39 PM
Your console output is perfectly consistent with an image which has already lost its trailer.  First, confirm that the previewimage exists with this command before trying to remove it:

exiftool -previewimage FILE

If the trailer is missing then this command will return "Error reading PreviewImage from file".

- Phil