Cannot get rid of PreviewImage

Started by bmn, August 03, 2013, 08:45:22 AM

Previous topic - Next topic

bmn

I want to get rid of the big PreviewImage, but exiftool 9.01 just won't do it.

$ exiftool -s cloud.jpg | grep -i preview
PreviewImageSize                : 1440x1080
PreviewImage                    : (Binary data 245391 bytes, use -b option to extract)
$ cp cloud.jpg a.jpg; exiftool -tagsFromFile cloud.jpg -PreviewImage= -trailer:all= -overwrite_original a.jpg;
    1 image files updated
$ exiftool -s a.jpg | grep -i preview
PreviewImageSize                : 1440x1080
PreviewImage                    : (Binary data 245391 bytes, use -b option to extract)


Phil Harvey

Removing the trailer removed the PreviewImage, but the pointers are still there so ExifTool reports it as if it still existed.  But if you try to extract it specifically ExifTool will actually check to see if it is valid:

> exiftool cloud.jpg -previewimage
Warning: [minor] Error reading PreviewImage from file - a.jpg


You should also notice that the image is 245 kB smaller after removing the trailer.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bmn

Is there a way to reset the PreviewImage field, such that exiftool at least reports "0x0" and "Binary data 0 bytes"? Seems -PreviewImageSize=0x0 or =1x1 is ignored.

By the way, exiftool modifies the FocalLength35efl value from 6.8mm to 6.9mm somewhat unexpectedly, and adds additional flash tags:

$ cp cloud.jpg a.jpg; exiftool -tagsFromFile cloud.jpg -PreviewImage= -trailer:All= -PreviewImageSize=1x1 -overwrite_original a.jpg
$ diff -dpru <(exiftool -s cloud.jpg | sort) <(exiftool -s a.jpg | sort)
--- /dev/fd/63  2013-08-04 11:33:39.468637812 +0200
+++ /dev/fd/62  2013-08-04 11:33:39.469637820 +0200
@@ -34,18 +34,23 @@ FNumber                         : 4.0
FaceInfoLength                  : 37
FaceInfoOffset                  : 94
FacesDetected                   : 0
-FileModifyDate                  : 2013:07:30 23:21:00+02:00
-FileName                        : cloud.jpg
+FileModifyDate                  : 2013:08:04 11:30:04+02:00
+FileName                        : a.jpg
FilePermissions                 : rw-r--r--
-FileSize                        : 1770 kB
+FileSize                        : 1533 kB
FileSource                      : Digital Camera
FileType                        : JPEG
Flash                           : Off, Did not fire
FlashExposureComp               : 0
+FlashFired                      : False
+FlashFunction                   : False
FlashLevel                      : Normal
+FlashMode                       : Off
+FlashRedEyeMode                 : False
+FlashReturn                     : No return detection
FlashpixVersion                 : 0100
FocalLength                     : 6.9 mm
-FocalLength35efl                : 6.8 mm
+FocalLength35efl                : 6.9 mm
FocusMode                       : Unknown (0)
HDR                             : Off; Uncorrected image
ISO                             : 100
@@ -66,7 +71,7 @@ MPFVersion                      : 0100
MPImageFlags                    : Dependent child image
MPImageFormat                   : JPEG
MPImageLength                   : 245391
-MPImageStart                    : 1566720
+MPImageStart                    : 1570707
MPImageType                     : Large Thumbnail (full HD equivalent)
Macro                           : Off
Make                            : SONY
@@ -112,9 +117,10 @@ SonyImageHeight                 : 2736
SonyImageWidth                  : 3648
ThumbnailImage                  : (Binary data 7679 bytes, use -b option to extract)
ThumbnailLength                 : 7679
-ThumbnailOffset                 : 38984
+ThumbnailOffset                 : 38926
UserComment                     :
WhiteBalance                    : Auto
+XMPToolkit                      : Image::ExifTool 9.01
XResolution                     : 350
YCbCrPositioning                : Co-sited
YCbCrSubSampling                : YCbCr4:2:2 (2 1)

Phil Harvey

These Sony images store an MPF preview, so to delete it completely, do this:

exiftool -mpf:all= -trailer:all= FILE

Then the only vestige remaining will be the Sony:PreviewImageSize

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bmn

That ended in:

Warning: Not a deletable group: mpf

Phil Harvey

Try updating to a more recent version of ExifTool.  The ability to delete the MPF segment was added in version 9.14.

And I forgot to comment on the other information that you say was changed.  I think you did something else to the image.  I get this:

cp tmp/cloud.jpg a.jpg
> exiftool a.jpg -a -u -G1 > t1
> exiftool a.jpg -PreviewImage= -trailer:all=
    1 image files updated
> exiftool a.jpg -a -u -G1 > t2
> diff t1 t2
4,7c4,7
< [System]        File Size                       : 1770 kB
< [System]        File Modification Date/Time     : 2013:08:03 08:45:21-04:00
< [System]        File Access Date/Time           : 2013:08:03 19:21:49-04:00
< [System]        File Inode Change Date/Time     : 2013:08:04 09:05:59-04:00
---
> [System]        File Size                       : 1529 kB
> [System]        File Modification Date/Time     : 2013:08:04 09:06:21-04:00
> [System]        File Access Date/Time           : 2013:08:04 09:06:21-04:00
> [System]        File Inode Change Date/Time     : 2013:08:04 09:06:21-04:00
147c147
< [IFD1]          Thumbnail Offset                : 38984
---
> [IFD1]          Thumbnail Offset                : 38982
163c163
< [MPImage2]      MP Image Start                  : 1566720
---
> [MPImage2]      MP Image Start                  : 1566719


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bmn

Thank you very much. Did not expect to see that many updates, but it is nevertheless a good thing. exiftool 9.34 does all I want.