source: main/trunk/greenstone2/perllib/cpan/Image/ExifTool/Scalado.pm@ 34921

Last change on this file since 34921 was 34921, checked in by anupama, 3 years ago

Committing the improvements to EmbeddedMetaPlugin's processing of Keywords vs other metadata fields. Keywords were literally stored as arrays of words rather than phrases in PDFs (at least in Diego's sample PDF), whereas other meta fields like Subjects and Creators stored them as arrays of phrases. To get both to work, Kathy updated EXIF to a newer version, to retrieve the actual EXIF values stored in the PDF. And Kathy and Dr Bainbridge came up with a new option that I added called apply_join_before_split_to_metafields that's a regex which can list the metadata fields to apply the join_before_split to and whcih previously always got applied to all metadata fields. Now it's applied to any *Keywords metafields by default, as that's the metafield we have experience of that behaves differently to the others, as it stores by word instead of phrases. Tested on Diego's sample PDF. Diego has double-checked it to works on his sample PDF too, setting the split char to ; and turning on the join_before_split and leaving apply_join_before_split_to_metafields at its default of .*Keywords. File changes are strings.properties for the tooltip, the plugin introducing the option and working with it and Kathy's EXIF updates affecting cpan/File and cpan/Image.

File size: 3.9 KB
Line 
1#------------------------------------------------------------------------------
2# File: Scalado.pm
3#
4# Description: Read APP4 SCALADO metadata
5#
6# Revisions: 2013-09-13 - P. Harvey Created
7#------------------------------------------------------------------------------
8
9package Image::ExifTool::Scalado;
10
11use strict;
12use vars qw($VERSION);
13use Image::ExifTool qw(:DataAccess :Utils);
14use Image::ExifTool::PLIST;
15
16$VERSION = '1.01';
17
18sub ProcessScalado($$$);
19
20# JPEG APP4 SCALADO tags
21%Image::ExifTool::Scalado::Main = (
22 GROUPS => { 0 => 'APP4', 1 => 'Scalado', 2 => 'Image' },
23 PROCESS_PROC => \&ProcessScalado,
24 TAG_PREFIX => 'Scalado',
25 FORMAT => 'int32s',
26 NOTES => q{
27 Tags extracted from the JPEG APP4 "SCALADO" segment found in images from
28 HTC, LG and Samsung phones. (Presumably written by Scalado mobile software,
29 L<http://www.scalado.com/>.)
30 },
31 SPMO => {
32 Name => 'DataLength',
33 Unknown => 1,
34 },
35 WDTH => {
36 Name => 'PreviewImageWidth',
37 ValueConv => '$val ? abs($val) : undef',
38 },
39 HGHT => {
40 Name => 'PreviewImageHeight',
41 ValueConv => '$val ? abs($val) : undef',
42 },
43 QUAL => {
44 Name => 'PreviewQuality',
45 ValueConv => '$val ? abs($val) : undef',
46 },
47 # tags not yet decoded with observed values:
48 # CHKH: 0, various negative values
49 # CHKL: various negative values
50 # CLEN: -1024
51 # CSPC: -2232593
52 # DATA: (+ve data length)
53 # HDEC: 0
54 # MAIN: 0, 60
55 # META: 24
56 # SCI0: (+ve data length) often 36
57 # SCI1: (+ve data length) 36
58 # SCX0: (+ve data length)
59 # SCX1: (+ve data length) often 84
60 # WDEC: 0
61 # VERS: -131328
62);
63
64#------------------------------------------------------------------------------
65# Extract information from the JPEG APP4 SCALADO segment
66# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
67# Returns: 1 on success
68sub ProcessScalado($$$)
69{
70 my ($et, $dirInfo, $tagTablePtr) = @_;
71 my $dataPt = $$dirInfo{DataPt};
72 my $pos = 0;
73 my $end = length $$dataPt;
74 my $unknown = $et->Options('Unknown');
75
76 $et->VerboseDir('APP4 SCALADO', undef, $end);
77 SetByteOrder('MM');
78
79 for (;;) {
80 last if $pos + 12 > $end;
81 my $tag = substr($$dataPt, $pos, 4);
82 my $ver = Get32u($dataPt, $pos + 4); # (looks like a version for some tags)
83 if (not $$tagTablePtr{$tag} and $unknown) {
84 my $name = $tag;
85 $name =~ tr/-A-Za-z0-9_//dc;
86 last unless length $name; # stop if tag is garbage
87 AddTagToTable($tagTablePtr, $tag, {
88 Name => "Scalado_$name",
89 Description => "Scalado $name",
90 Unknown => 1,
91 });
92 }
93 $et->HandleTag($tagTablePtr, $tag, undef,
94 DataPt => $dataPt,
95 Start => $pos + 8,
96 Size => 4,
97 Extra => ", ver $ver",
98 );
99 if ($tag eq 'SPMO') {
100 my $val = Get32u($dataPt, $pos + 8) ;
101 if ($ver < 5) { # (I don't have samples for version 3 or 4, so I'm not sure about these)
102 $end -= $val; # SPMO gives trailer data length
103 } else {
104 $end = $val + 12; # SPMO gives length of Scalado directory (excepting this entry)
105 }
106 }
107 $pos += 12;
108 }
109 return 1;
110}
111
1121; # end
113
114__END__
115
116=head1 NAME
117
118Image::ExifTool::Scalado - Read APP4 SCALADO metadata
119
120=head1 SYNOPSIS
121
122This module is loaded automatically by Image::ExifTool when required.
123
124=head1 DESCRIPTION
125
126This module contains definitions required by Image::ExifTool to read
127metadata from the JPEG APP4 SCALADO segment.
128
129=head1 AUTHOR
130
131Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
132
133This library is free software; you can redistribute it and/or modify it
134under the same terms as Perl itself.
135
136=head1 SEE ALSO
137
138L<Image::ExifTool::TagNames/Scalado Tags>,
139L<Image::ExifTool(3pm)|Image::ExifTool>
140
141=cut
Note: See TracBrowser for help on using the repository browser.