exiftool_vendored 12.97.0 → 12.99.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,8 +39,7 @@ sub SerializeStruct($$;$)
39
39
 
40
40
  if (ref $obj eq 'HASH') {
41
41
  # support hashes with ordered keys
42
- my @keys = $$obj{_ordered_keys_} ? @{$$obj{_ordered_keys_}} : sort keys %$obj;
43
- foreach $key (@keys) {
42
+ foreach $key (Image::ExifTool::OrderedKeys($obj)) {
44
43
  my $hdr = $sfmt ? EscapeJSON($key) . ':' : $key . '=';
45
44
  push @vals, $hdr . SerializeStruct($et, $$obj{$key}, '}');
46
45
  }
@@ -218,7 +217,7 @@ sub DumpStruct($;$)
218
217
  $indent or $indent = '';
219
218
  if (ref $obj eq 'HASH') {
220
219
  print "{\n";
221
- foreach (sort keys %$obj) {
220
+ foreach (Image::ExifTool::OrderedKeys($obj)) {
222
221
  print "$indent $_ = ";
223
222
  DumpStruct($$obj{$_}, "$indent ");
224
223
  }
@@ -253,8 +252,10 @@ sub CheckStruct($$$)
253
252
  ref $struct eq 'HASH' or return wantarray ? (undef, "Expecting $strName structure") : undef;
254
253
 
255
254
  my ($key, $err, $warn, %copy, $rtnVal, $val);
255
+ # copy the ordered keys if they exist
256
+ $copy{_ordered_keys_} = [ ] if $$struct{_ordered_keys_};
256
257
  Key:
257
- foreach $key (keys %$struct) {
258
+ foreach $key (Image::ExifTool::OrderedKeys($struct)) {
258
259
  my $tag = $key;
259
260
  # allow trailing '#' to disable print conversion on a per-field basis
260
261
  my ($type, $fieldInfo);
@@ -377,6 +378,7 @@ Key:
377
378
  $copy{$tag} = \@copy;
378
379
  } elsif ($$fieldInfo{Struct}) {
379
380
  $warn = "Improperly formed structure in $strName $tag";
381
+ next;
380
382
  } else {
381
383
  $et->Sanitize(\$$struct{$key});
382
384
  ($val,$err) = $et->ConvInv($$struct{$key},$fieldInfo,$tag,$strName,$type,'');
@@ -387,6 +389,7 @@ Key:
387
389
  # turn this into a list if necessary
388
390
  $copy{$tag} = $$fieldInfo{List} ? [ $val ] : $val;
389
391
  }
392
+ push @{$copy{_ordered_keys_}}, $tag if $copy{_ordered_keys_}; # save ordered keys
390
393
  }
391
394
  if (%copy or not $warn) {
392
395
  $rtnVal = \%copy;
@@ -562,7 +565,7 @@ sub AddNewStruct($$$$$$)
562
565
  # after all valid structure fields, which is necessary when serializing the XMP later)
563
566
  %$struct or $$struct{'~dummy~'} = '';
564
567
 
565
- foreach $tag (sort keys %$struct) {
568
+ foreach $tag (Image::ExifTool::OrderedKeys($struct)) {
566
569
  my $fieldInfo = $$strTable{$tag};
567
570
  unless ($fieldInfo) {
568
571
  next unless $tag eq '~dummy~'; # check for dummy field
@@ -652,7 +655,8 @@ sub ConvertStruct($$$$;$)
652
655
  my (%struct, $key);
653
656
  my $table = $$tagInfo{Table};
654
657
  $parentID = $$tagInfo{TagID} unless $parentID;
655
- foreach $key (keys %$value) {
658
+ $struct{_ordered_keys_} = [ ] if $$value{_ordered_keys_};
659
+ foreach $key (Image::ExifTool::OrderedKeys($value)) {
656
660
  my $tagID = $parentID . ucfirst($key);
657
661
  my $flatInfo = $$table{$tagID};
658
662
  unless ($flatInfo) {
@@ -669,7 +673,11 @@ sub ConvertStruct($$$$;$)
669
673
  } else {
670
674
  $v = $et->GetValue($flatInfo, $type, $v);
671
675
  }
672
- $struct{$key} = $v if defined $v; # save the converted value
676
+ if (defined $v) {
677
+ $struct{$key} = $v; # save the converted value
678
+ # maintain ordered keys if necessary
679
+ push @{$struct{_ordered_keys_}}, $key if $struct{_ordered_keys_};
680
+ }
673
681
  }
674
682
  return \%struct;
675
683
  } elsif (ref $value eq 'ARRAY') {
@@ -29,7 +29,7 @@ use vars qw($VERSION $RELEASE @ISA @EXPORT_OK %EXPORT_TAGS $AUTOLOAD @fileTypes
29
29
  %jpegMarker %specialTags %fileTypeLookup $testLen $exeDir
30
30
  %static_vars $advFmtSelf);
31
31
 
32
- $VERSION = '12.97';
32
+ $VERSION = '12.99';
33
33
  $RELEASE = '';
34
34
  @ISA = qw(Exporter);
35
35
  %EXPORT_TAGS = (
@@ -37,7 +37,7 @@ $RELEASE = '';
37
37
  Public => [qw(
38
38
  ImageInfo AvailableOptions GetTagName GetShortcuts GetAllTags
39
39
  GetWritableTags GetAllGroups GetDeleteGroups GetFileType CanWrite
40
- CanCreate AddUserDefinedTags
40
+ CanCreate AddUserDefinedTags OrderedKeys
41
41
  )],
42
42
  # exports not part of the public API, but used by ExifTool modules:
43
43
  DataAccess => [qw(
@@ -1466,12 +1466,12 @@ my %systemTagsNotes = (
1466
1466
  PrintConv => sub {
1467
1467
  my ($mask, $val) = (0400, oct(shift));
1468
1468
  my %types = (
1469
- 0010000 => 'p',
1470
- 0020000 => 'c',
1471
- 0040000 => 'd',
1472
- 0060000 => 'b',
1473
- 0120000 => 'l',
1474
- 0140000 => 's',
1469
+ 0010000 => 'p', # FIFO
1470
+ 0020000 => 'c', # character special file
1471
+ 0040000 => 'd', # directory
1472
+ 0060000 => 'b', # block special file
1473
+ 0120000 => 'l', # sym link
1474
+ 0140000 => 's', # socket link
1475
1475
  );
1476
1476
  my $str = $types{$val & 0170000} || '-';
1477
1477
  while ($mask) {
@@ -2292,6 +2292,7 @@ sub new
2292
2292
  $$self{PATH} = [ ]; # (this too)
2293
2293
  $$self{DEL_GROUP} = { }; # lookup for groups to delete when writing
2294
2294
  $$self{SAVE_COUNT} = 0; # count calls to SaveNewValues()
2295
+ $$self{NV_COUNT} = 0; # count of NEW_VALUE entries
2295
2296
  $$self{FILE_SEQUENCE} = 0; # sequence number for files when reading
2296
2297
  $$self{FILES_WRITTEN} = 0; # count of files successfully written
2297
2298
  $$self{INDENT2} = ''; # indentation of verbose messages from SetNewValue
@@ -2517,6 +2518,8 @@ sub Options($$;@)
2517
2518
  # set Compact and XMPShorthand options, preserving backward compatibility
2518
2519
  my ($p, %compact);
2519
2520
  foreach $p ('Compact','XMPShorthand') {
2521
+ # (allow setting from a HASH (undocumented)
2522
+ ref $newVal eq 'HASH' and %compact = %{$newVal}, next;
2520
2523
  my $val = $param eq $p ? $newVal : $$options{Compact}{$p};
2521
2524
  if (defined $val) {
2522
2525
  my @v = ($val =~ /\w+/g);
@@ -4195,6 +4198,16 @@ sub CanCreate($)
4195
4198
  return 0;
4196
4199
  }
4197
4200
 
4201
+ #------------------------------------------------------------------------------
4202
+ # Return list of ordered keys if available, otherwise just sort alphabetically
4203
+ # Inputs: 0) hash ref
4204
+ # Returns: List of ordered/sorted keys
4205
+ sub OrderedKeys($)
4206
+ {
4207
+ my $hash = shift;
4208
+ return $$hash{_ordered_keys_} ? @{$$hash{_ordered_keys_}} : sort keys %$hash;
4209
+ }
4210
+
4198
4211
  #==============================================================================
4199
4212
  # Functions below this are not part of the public API
4200
4213
 
@@ -7290,7 +7303,10 @@ sub ProcessJPEG($$;$)
7290
7303
  last; # all done parsing file
7291
7304
  } elsif (defined $markerLenBytes{$marker}) {
7292
7305
  # handle other stand-alone markers and segments we skipped over
7293
- $verbose and $marker and print $out "${indent}JPEG $markerName\n";
7306
+ if ($verbose and $marker) {
7307
+ next if $verbose < 4 and ($marker & 0xf8) == 0xd0;
7308
+ print $out "${indent}JPEG $markerName\n";
7309
+ }
7294
7310
  next;
7295
7311
  } elsif ($marker == 0xdb and length($$segDataPt) and # DQT
7296
7312
  # save the DQT data only if JPEGDigest has been requested
@@ -7901,8 +7917,17 @@ sub ProcessJPEG($$;$)
7901
7917
  my $seq = Get32u($segDataPt, 4);
7902
7918
  my $len = Get32u($segDataPt, 8);
7903
7919
  my $type = substr($$segDataPt, 12, 4);
7920
+ # a Microsoft bug writes $len and $type incorrectly as little-endian
7921
+ if ($type eq 'bmuj') {
7922
+ $self->WarnOnce('Wrong byte order in C2PA APP11 JUMBF header');
7923
+ $type = 'jumb';
7924
+ $len = unpack('x8V', $$segDataPt);
7925
+ # fix the header
7926
+ substr($$segDataPt, 8, 8) = Set32u($len) . $type;
7927
+ }
7904
7928
  my $hdrLen;
7905
7929
  if ($len == 1 and length($$segDataPt) >= 24) {
7930
+ # (haven't seen this with the Microsoft bug)
7906
7931
  $len = Get64u($$segDataPt, 16);
7907
7932
  $hdrLen = 16;
7908
7933
  } else {
@@ -332,13 +332,14 @@ L</ImageInfo>:
332
332
 
333
333
  Values of the returned hash are usually simple scalars, but a scalar
334
334
  reference is used to indicate binary data and an array reference may be used
335
- to indicate a list. Also, a hash reference may be returned if the L</Struct>
336
- option is used. Lists of values are joined by commas into a single
337
- string only if the PrintConv option is enabled and the ListJoin option is
338
- enabled (which are the defaults). Note that binary values are not
339
- necessarily extracted unless specifically requested, or the Binary option is
340
- enabled and the tag is not specifically excluded. If not extracted the
341
- value is a reference to a string of the form "Binary data ##### bytes".
335
+ to indicate a list. Also, a hash reference may be returned if the
336
+ L</Struct> option is used (see the L</OrderedKeys> option to obtain the hash
337
+ keys). Lists of values are joined by commas into a single string only if
338
+ the PrintConv option is enabled and the ListJoin option is enabled (which
339
+ are the defaults). Note that binary values are not necessarily extracted
340
+ unless specifically requested, or the Binary option is enabled and the tag
341
+ is not specifically excluded. If not extracted the value is a reference to
342
+ a string of the form "Binary data ##### bytes".
342
343
 
343
344
  The code below gives an example of how to handle these return values, as
344
345
  well as illustrating the use of other ExifTool functions:
@@ -1089,7 +1090,9 @@ values in standard format).
1089
1090
 
1090
1091
  Flag to return XMP structures as hash references instead of flattening into
1091
1092
  individual tags. Has no effect when writing since both flattened and
1092
- structured tags may always be written. Possible values are:
1093
+ structured tags may always be written. A special "_ordered_keys_" element
1094
+ containing a list of ordered keys may exist if the structure elements are
1095
+ ordered (see the L<OrderedKeys> method). Possible values are:
1093
1096
 
1094
1097
  undef - (default) Same as 0 for reading, 2 for copying
1095
1098
  0 - Read/copy flattened tags
@@ -2749,6 +2752,26 @@ details on the elements of the tag information hash.
2749
2752
 
2750
2753
  =back
2751
2754
 
2755
+ =head2 OrderedKeys [static]
2756
+
2757
+ Return a list of ordered keys from a tag value that is a HASH reference
2758
+ when the Struct option is used.
2759
+
2760
+ use Image::ExifTool ':Public';
2761
+ my @keys = OrderedKeys($structRef);
2762
+
2763
+ =over 4
2764
+
2765
+ =item Inputs:
2766
+
2767
+ 0) Structure HASH reference
2768
+
2769
+ =item Return Value:
2770
+
2771
+ List of ordered keys, or sorted alphabetically if not ordered.
2772
+
2773
+ =back
2774
+
2752
2775
  =head1 CHARACTER ENCODINGS
2753
2776
 
2754
2777
  Certain meta information formats allow coded character sets other than plain
@@ -1,6 +1,6 @@
1
1
  Summary: perl module for image data extraction
2
2
  Name: perl-Image-ExifTool
3
- Version: 12.97
3
+ Version: 12.99
4
4
  Release: 1
5
5
  License: Artistic/GPL
6
6
  Group: Development/Libraries/Perl
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExiftoolVendored
4
- VERSION = Gem::Version.new('12.97.0')
4
+ VERSION = Gem::Version.new('12.99.0')
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exiftool_vendored
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.97.0
4
+ version: 12.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-25 00:00:00.000000000 Z
12
+ date: 2024-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: exiftool