Emit blanks in metadata values?

Started by Mac2, November 08, 2020, 05:37:39 AM

Previous topic - Next topic


Regarding this thread (https://exiftool.org/forum/index.php?topic=11663.0) I wondered how I could make ExifTool include blanks in the output.
The file in question had additional blanks in the make/model tag. I was able to see them in a binary editor, but I was unable to produce output with ExifTool that included these blanks.

I tried various things and checked the docs, but I could not find a "Don't trim" command line argument...?

For example, when I do a >exiftool -php -exif:make -exif:model filename I get

  "ImageDescription" => "OLYMPUS DIGITAL CAMERA         ",
  "Model" => "PEN-F",

Trailing blanks in the description, but none in the make/model.
Similar for JSON output or piping into a text file. I use Windows.

Is there a flag I need to use to see the actual data? I tried -b too, but to no avail.

Phil Harvey

The Make and Model tags are handled specially because they are used as keys to decide the formatting of the maker notes (amongst other things), so you can't avoid trimming these with any command-line option.  Instead,  you could override the Make and Model tag definitions with user-defined tags to avoid trimming the spaces.  Here is a config file that would do this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Exif::Main' => {
        0x10f => {
            Name => 'Make',
            Groups => { 2 => 'Camera' },
            Writable => 'string',
            WriteGroup => 'IFD0',
            DataMember => 'Make',
            RawConv => '($$self{Make} = $val) =~ s/\s+$//; $val',
        0x110 => {
            Name => 'Model',
            Description => 'Camera Model Name',
            Groups => { 2 => 'Camera' },
            Writable => 'string',
            WriteGroup => 'IFD0',
            DataMember => 'Model',
            RawConv => '($$self{Model} = $val) =~ s/\s+$//; $val',
1; #end

Note that I'm still trimming the internal Make and Model variables to avoid breaking the makernote recognition, but the tag value won't be trimmed any more.

- 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 ($).


Ah, that explains that. It's always easy when you know how  ;)
I will file that away for when I need it again.

I generally try not to fiddle with the way ExifTool works, because that way it works best.

It's only the rare fringe cases like SilkyPix refusing to load an image because it expects a certain number of trailing blanks in the make tag which require this kind treatment.
Thanks again for figuring out the problem. SilkyPix has fixed it now, too.