ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: swiss_knight on March 10, 2023, 03:03:36 PM

Title: Removing the NUL ASCII char (00 hex) sometimes seen at the end of a tag value
Post by: swiss_knight on March 10, 2023, 03:03:36 PM
Hello.

I succeeded in extracting some image metadata with Exiftool 12.57 on Ubuntu 22.04 but I noticed in some cases some strange behaviour when I was further trying to insert data into a database.

The incriminated line in the resulting CSV file is as follow:

/file_003.jpg,1154.28 m,Above Sea Level,2018:02:28,,,,,,,,45.4086491,North,75.6882509,West,,,GPS,,,,,16:27:50,,,2.2.0.0

When I open the file with an advanced text editor, I noticed a strange "red dot" after the word "GPS":

(https://i.stack.imgur.com/1XBKm.png)


I decided to explore this further, and I opened the file with an hexadecimal editor, where I noticed that this little red dot is actually the hex value 00 (00000000 as a binary value).

When trying to insert this line from my CSV file into a database, the number of data mismatches the number of columns defined by the header of the CSV file. But if I remove that special NUL character (00 hex apparently means NUL in the ASCII table), it goes well.


Is there something I can do within exiftool to avoid such NUL value?

My command looks like this for the moment:

exiftool -EXIF:GPS* -G0 --b -c '%.7f' -csv "${FILE}"

If need be:

$ exiftool -G0:1  -a -s "${FILE}"
[ExifTool]      ExifToolVersion                 : 12.57
[ExifTool]      Warning                         : [minor] Unrecognized MakerNotes
[ExifTool]      Warning                         : [minor] Unrecognized MakerNotes
[File:System]   FileName                        : file_003.jpg
[File:System]   Directory                       : /
[File:System]   FileSize                        : 4.8 MB
[File:System]   FileModifyDate                  : 2018:02:28 17:27:52+01:00
[File:System]   FileAccessDate                  : 2023:03:10 11:18:50+01:00
[File:System]   FileInodeChangeDate             : 2023:03:02 15:06:33+01:00
[File:System]   FilePermissions                 : -rw-rw-r--
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Big-endian (Motorola, MM)
[File]          ImageWidth                      : 3968
[File]          ImageHeight                     : 2976
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:0 (2 2)
[EXIF:IFD0]     ImageWidth                      : 3968
[EXIF:IFD0]     ImageHeight                     : 2976
[EXIF:IFD0]     BitsPerSample                   : 8 8 8
[EXIF:IFD0]     ImageDescription                : sdr
[EXIF:IFD0]     Make                            : HUAWEI
[EXIF:IFD0]     Model                           : PIC-LX9
[EXIF:IFD0]     Orientation                     : Unknown (0)
[EXIF:IFD0]     XResolution                     : 72
[EXIF:IFD0]     YResolution                     : 72
[EXIF:IFD0]     ResolutionUnit                  : inches
[EXIF:IFD0]     Software                        : PIC-LX9C432B130
[EXIF:IFD0]     ModifyDate                      : 2018:02:28 17:27:52
[EXIF:IFD0]     YCbCrPositioning                : Centered
[EXIF:IFD0]     DeviceSettingDescription        : (Binary data 4 bytes, use -b option to extract)
[EXIF:ExifIFD]  DocumentName                    :
[EXIF:ExifIFD]  ExposureTime                    : 1/50
[EXIF:ExifIFD]  FNumber                         : 1.8
[EXIF:ExifIFD]  ExposureProgram                 : Program AE
[EXIF:ExifIFD]  ISO                             : 160
[EXIF:ExifIFD]  ExifVersion                     : 0210
[EXIF:ExifIFD]  DateTimeOriginal                : 2018:02:28 17:27:52
[EXIF:ExifIFD]  CreateDate                      : 2018:02:28 17:27:52
[EXIF:ExifIFD]  ComponentsConfiguration         : Y, Cb, Cr, -
[EXIF:ExifIFD]  ShutterSpeedValue               : 1/999963365
[EXIF:ExifIFD]  ApertureValue                   : 1.8
[EXIF:ExifIFD]  BrightnessValue                 : 0
[EXIF:ExifIFD]  ExposureCompensation            : 0
[EXIF:ExifIFD]  MeteringMode                    : Multi-segment
[EXIF:ExifIFD]  LightSource                     : Daylight
[EXIF:ExifIFD]  Flash                           : No Flash
[EXIF:ExifIFD]  FocalLength                     : 3.8 mm
[EXIF:ExifIFD]  MakerNoteUnknownText            : Auto
[EXIF:ExifIFD]  SubSecTime                      : 713446
[EXIF:ExifIFD]  SubSecTimeOriginal              : 713446
[EXIF:ExifIFD]  SubSecTimeDigitized             : 713446
[EXIF:ExifIFD]  FlashpixVersion                 : 0100
[EXIF:ExifIFD]  ColorSpace                      : sRGB
[EXIF:ExifIFD]  ExifImageWidth                  : 3968
[EXIF:ExifIFD]  ExifImageHeight                 : 2976
[EXIF:ExifIFD]  SensingMethod                   : One-chip color area
[EXIF:ExifIFD]  FileSource                      : Digital Camera
[EXIF:ExifIFD]  SceneType                       : Directly photographed
[EXIF:ExifIFD]  CustomRendered                  : Custom
[EXIF:ExifIFD]  ExposureMode                    : Auto
[EXIF:ExifIFD]  WhiteBalance                    : Auto
[EXIF:ExifIFD]  DigitalZoomRatio                : 1
[EXIF:ExifIFD]  FocalLengthIn35mmFormat         : 27 mm
[EXIF:ExifIFD]  SceneCaptureType                : Standard
[EXIF:ExifIFD]  GainControl                     : None
[EXIF:ExifIFD]  Contrast                        : Normal
[EXIF:ExifIFD]  Saturation                      : Normal
[EXIF:ExifIFD]  Sharpness                       : Normal
[EXIF:ExifIFD]  SubjectDistanceRange            : Unknown
[EXIF:InteropIFD] InteropIndex                  : R98 - DCF basic file (sRGB)
[EXIF:InteropIFD] InteropVersion                : 0100
[EXIF:GPS]      GPSVersionID                    : 2.2.0.0
[EXIF:GPS]      GPSLatitudeRef                  : North
[EXIF:GPS]      GPSLatitude                     : 45.4086491
[EXIF:GPS]      GPSLongitudeRef                 : West
[EXIF:GPS]      GPSLongitude                    : 75.6882509
[EXIF:GPS]      GPSAltitudeRef                  : Above Sea Level
[EXIF:GPS]      GPSAltitude                     : 1154.28 m
[EXIF:GPS]      GPSTimeStamp                    : 16:27:50
[EXIF:GPS]      GPSProcessingMethod             : GPS
[EXIF:GPS]      GPSDateStamp                    : 2018:02:28
[EXIF:IFD1]     ImageWidth                      : 512
[EXIF:IFD1]     ImageHeight                     : 384
[EXIF:IFD1]     Compression                     : JPEG (old-style)
[EXIF:IFD1]     Orientation                     : Unknown (0)
[EXIF:IFD1]     XResolution                     : 72
[EXIF:IFD1]     YResolution                     : 72
[EXIF:IFD1]     ResolutionUnit                  : inches
[EXIF:IFD1]     ThumbnailOffset                 : 8814
[EXIF:IFD1]     ThumbnailLength                 : 44934
[EXIF:IFD1]     ThumbnailImage                  : (Binary data 44934 bytes, use -b option to extract)
[JFIF]          JFIFVersion                     : 1.01
[JFIF]          ResolutionUnit                  : inches
[JFIF]          XResolution                     : 96
[JFIF]          YResolution                     : 96

I also have the exact same trouble on the tag "EXIF:MakerNoteUnknownText" with another HUAWEI camera (VOG-L29).


Thank you for your valuable help and for providing us this really great and exhaustive tool.

PS: as a workaround, I would be glad if it could be possible to "test" for the camera make with some kind of 'if statement' within the command (I actually run it on a whole bunch of folders using the -r option): if camera make == HUAWEI => simply do not consider the image.
Title: Re: Removing the NUL ASCII char (00 hex) sometimes seen at the end of a tag value
Post by: Phil Harvey on March 10, 2023, 03:58:34 PM
This is likely due to one of GPS tags being stored incorrectly.

If you could send me the image with this problem I'll take a look.  My email is philharvey66 at gmail.com

(but I'm not sure your --b is doing what you indend.  There is no --b option.)

- Phil