@@ -11,7 +11,7 @@ use strict;
1111use warnings;
1212require 5.004;
1313
14- my $version = ' 13.00 ' ;
14+ my $version = ' 13.02 ' ;
1515
1616# add our 'lib' directory to the include list BEFORE 'use Image::ExifTool'
1717my $exePath ;
@@ -63,6 +63,7 @@ sub AddSetTagsFile($;$);
6363sub Warning ($$);
6464sub DoSetFromFile ($$$);
6565sub CleanFilename ($);
66+ sub HasWildcards ($);
6667sub SetWindowTitle ($);
6768sub ProcessFiles ($;$);
6869sub ScanDir ($$;$);
@@ -856,7 +857,7 @@ for (;;) {
856857 } else {
857858 print " Available API Options:\n " ;
858859 my $availableOptions = Image::ExifTool::AvailableOptions();
859- printf (" %-17s - %s \n " , $$_ [0], $$_ [2]) foreach @$availableOptions ;
860+ $$_ [3] or printf (" %-17s - %s \n " , $$_ [0], $$_ [2]) foreach @$availableOptions ;
860861 $helped = 1;
861862 }
862863 next ;
@@ -1039,7 +1040,7 @@ for (;;) {
10391040 }
10401041 $trkfile or Error(" Expecting file name for -geotag option\n " ), $badCmd =1, next ;
10411042 # allow wildcards in filename
1042- if ($trkfile =~ / [*?] / ) {
1043+ if (HasWildcards( $trkfile ) ) {
10431044 # CORE::glob() splits on white space, so use File::Glob if possible
10441045 my @trks ;
10451046 if ($^O eq ' MSWin32' and eval { require Win32::FindFile }) {
@@ -1425,7 +1426,7 @@ for (;;) {
14251426 push @nextPass , $_ ;
14261427 next ;
14271428 }
1428- if ($doGlob and /[*?]/ ) {
1429+ if ($doGlob and HasWildcards( $_ ) ) {
14291430 if ($^O eq ' MSWin32' and eval { require Win32::FindFile }) {
14301431 push @files , FindFileWindows($mt , $_ );
14311432 } else {
@@ -1522,6 +1523,7 @@ if (($tagOut or defined $diff) and ($csv or $json or %printFmt or $tabFormat or
15221523}
15231524
15241525if ($csv and $csv eq ' CSV' and not $isWriting ) {
1526+ undef $json ; # (not compatible)
15251527 if ($textOut ) {
15261528 Warn " Sorry, -w may not be combined with -csv\n " ;
15271529 $rtnVal = 1;
@@ -1802,7 +1804,7 @@ if ($binaryOutput) {
18021804}
18031805
18041806# sort by groups to look nicer depending on options
1805- if (defined $showGroup and not (@tags and $allGroup ) and ($sortOpt or not defined $sortOpt )) {
1807+ if (defined $showGroup and not (@tags and ( $allGroup or $csv ) ) and ($sortOpt or not defined $sortOpt )) {
18061808 $mt -> Options(Sort => " Group$showGroup " );
18071809}
18081810
@@ -1840,7 +1842,7 @@ $altEnc = $mt->Options('Charset');
18401842undef $altEnc if $altEnc eq ' UTF8' ;
18411843
18421844# set flag to fix description lengths if necessary
1843- if (not $altEnc and $mt -> Options(' Lang' ) ne ' en' and eval { require Encode } ) {
1845+ if (not $altEnc and $mt -> Options(' Lang' ) ne ' en' ) {
18441846 # (note that Unicode::GCString is part of the Unicode::LineBreak package)
18451847 $fixLen = eval { require Unicode::GCString } ? 2 : 1;
18461848}
@@ -2621,7 +2623,13 @@ TAG: foreach $tag (@foundTags) {
26212623 # (note that the tag key may look like "TAG #(1)" when the "#" feature is used)
26222624 next if $noDups and $tag =~ / ^(.*?) ?\( / and defined $$info {$1 } and
26232625 $group eq $et -> GetGroup($1 , $showGroup );
2624- $group = ' Unknown' if not $group and ($xml or $json or $csv );
2626+ if (not $group and ($xml or $json or $csv )) {
2627+ if ($showGroup !~ / \b 4\b / ) {
2628+ $group = ' Unknown' ;
2629+ } elsif ($json and not $allGroup ) {
2630+ $group = ' Copy0' ;
2631+ }
2632+ }
26252633 if ($fp and not ($allGroup or $csv )) {
26262634 if ($lastGroup ne $group ) {
26272635 if ($html ) {
@@ -2843,6 +2851,9 @@ TAG: foreach $tag (@foundTags) {
28432851 my $num = $et -> GetValue($tag , ' ValueConv' );
28442852 $$val {num } = $num if defined $num and not IsEqual($num , $$val {val });
28452853 }
2854+ my $ex = $$et {TAG_EXTRA }{$tag };
2855+ $$val {' hex' } = join ' ' , unpack ' (H2)*' , $$ex {BinVal } if defined $$ex {BinVal };
2856+ $$val {' fmt' } = $$ex {G6 } if defined $$ex {G6 };
28462857 }
28472858 }
28482859 FormatJSON($fp , $val , $ind , $quote );
@@ -3838,17 +3849,23 @@ sub Printable($)
38383849sub LengthUTF8 ($)
38393850{
38403851 my $str = shift ;
3852+ return length $str unless $fixLen ;
3853+ local $SIG {' __WARN__' } = sub { };
3854+ if (not $$mt {OPTIONS }{EncodeHangs } and eval { require Encode }) {
3855+ $str = Encode::decode_utf8($str );
3856+ } else {
3857+ $str = pack (' U0C*' , unpack ' C*' , $str );
3858+ }
38413859 my $len ;
3842- if (not $fixLen ) {
3860+ if ($fixLen == 1 ) {
38433861 $len = length $str ;
3844- } elsif ($fixLen == 1) {
3845- $len = length Encode::decode_utf8($str );
38463862 } else {
3847- my $gcstr = eval { Unicode::GCString-> new(Encode::decode_utf8( $str ) ) };
3863+ my $gcstr = eval { Unicode::GCString-> new($str ) };
38483864 if ($gcstr ) {
38493865 $len = $gcstr -> columns;
38503866 } else {
3851- $len = length Encode::decode_utf8($str );
3867+ $len = length $str ;
3868+ delete $SIG {' __WARN__' };
38523869 Warning($mt , ' Unicode::GCString problem. Columns may be misaligned' );
38533870 $fixLen = 1;
38543871 }
@@ -3951,6 +3968,19 @@ sub CleanFilename($)
39513968 $_ [0] =~ tr / \\/ \// if Image::ExifTool::IsPC();
39523969}
39533970
3971+ # ------------------------------------------------------------------------------
3972+ # Does path name contain wildcards
3973+ # Inputs: 0) path name
3974+ # Returns: true if path contains wildcards
3975+ sub HasWildcards ($)
3976+ {
3977+ my $path = shift ;
3978+
3979+ # if this is a Windows path with the long path prefix, then wildcards are not supported
3980+ return 0 if $^O eq ' MSWin32' and $path =~ m { ^[\\ /]{2}\? [\\ /]} ;
3981+ return $path =~ / [*?]/ ;
3982+ }
3983+
39543984# ------------------------------------------------------------------------------
39553985# Check for valid UTF-8 of a file name
39563986# Inputs: 0) string, 1) original encoding
@@ -4071,7 +4101,7 @@ sub ScanDir($$;$)
40714101 return if $ignore {$dir };
40724102 # use Win32::FindFile on Windows if available
40734103 # (ReadDir will croak if there is a wildcard, so check for this)
4074- if ($^O eq ' MSWin32' and $dir !~ / [*?] / ) {
4104+ if ($^O eq ' MSWin32' and not HasWildcards( $dir ) ) {
40754105 undef $evalWarning ;
40764106 local $SIG {' __WARN__' } = sub { $evalWarning = $_ [0] };;
40774107 if (CheckUTF8($dir , $enc ) >= 0) {
@@ -4197,7 +4227,7 @@ sub FindFileWindows($$)
41974227 $wildfile = $et -> Decode($wildfile , $enc , undef , ' UTF8' ) if $enc and $enc ne ' UTF8' ;
41984228 $wildfile =~ tr / \\/ \// ; # use forward slashes
41994229 my ($dir , $wildname ) = ($wildfile =~ m { (.*[:/])(.*)} ) ? ($1 , $2 ) : (' ' , $wildfile );
4200- if ($dir =~ / [*?] / ) {
4230+ if (HasWildcards( $dir ) ) {
42014231 Warn " Wildcards don't work in the directory specification\n " ;
42024232 return ();
42034233 }
@@ -5682,16 +5712,17 @@ output as simple strings). The B<-a> option is implied when B<-json> is
56825712used, but entries with identical JSON names are suppressed in the output.
56835713(B<-G4 > may be used to ensure that all tags have unique JSON names.) Adding
56845714the B<-D > or B<-H > option changes tag values to JSON objects with "val" and
5685- "id" fields, and adding B<-l > adds a "desc" field, and a "num" field if the
5686- numerical value is different from the converted "val". The B<-b > option may
5687- be added to output binary data, encoded in base64 if necessary (indicated by
5688- ASCII "base64:" as the first 7 bytes of the value), and B<-t > may be added
5689- to include tag table information (see B<-t > for details). The JSON output
5690- is UTF-8 regardless of any B<-L > or B<-charset > option setting, but the
5691- UTF-8 validation is disabled if a character set other than UTF-8 is
5692- specified. Note that ExifTool quotes JSON values only if they don't look
5693- like numbers (regardless of the original storage format or the relevant
5694- metadata specification).
5715+ "id" fields. Adding B<-l > adds a "desc" field, and a "num" field if the
5716+ numerical value is different from the converted "val", and "fmt" and "hex"
5717+ fields for EXIF metadata if the API SaveFormat and SaveBin options are set
5718+ respectively. The B<-b > option may be added to output binary data, encoded
5719+ in base64 if necessary (indicated by ASCII "base64:" as the first 7 bytes of
5720+ the value), and B<-t > may be added to include tag table information (see
5721+ B<-t > for details). The JSON output is UTF-8 regardless of any B<-L > or
5722+ B<-charset > option setting, but the UTF-8 validation is disabled if a
5723+ character set other than UTF-8 is specified. Note that ExifTool quotes JSON
5724+ values only if they don't look like numbers (regardless of the original
5725+ storage format or the relevant metadata specification).
56955726
56965727If I<JSONFILE > is specified, the file is imported and the tag definitions
56975728from the file are used to set tag values on a per-file basis. The special
@@ -5845,7 +5876,7 @@ with this command:
58455876
58465877produces output like this:
58475878
5848- -- Generated by ExifTool 13.00 --
5879+ -- Generated by ExifTool 13.02 --
58495880 File: a.jpg - 2003:10:31 15:44:19
58505881 (f/5.6, 1/60s, ISO 100)
58515882 File: b.jpg - 2006:05:23 11:57:38
0 commit comments