1 | #------------------------------------------------------------------------------
|
---|
2 | # File: Scalado.pm
|
---|
3 | #
|
---|
4 | # Description: Read APP4 SCALADO metadata
|
---|
5 | #
|
---|
6 | # Revisions: 2013-09-13 - P. Harvey Created
|
---|
7 | #------------------------------------------------------------------------------
|
---|
8 |
|
---|
9 | package Image::ExifTool::Scalado;
|
---|
10 |
|
---|
11 | use strict;
|
---|
12 | use vars qw($VERSION);
|
---|
13 | use Image::ExifTool qw(:DataAccess :Utils);
|
---|
14 | use Image::ExifTool::PLIST;
|
---|
15 |
|
---|
16 | $VERSION = '1.01';
|
---|
17 |
|
---|
18 | sub 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
|
---|
68 | sub 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 |
|
---|
112 | 1; # end
|
---|
113 |
|
---|
114 | __END__
|
---|
115 |
|
---|
116 | =head1 NAME
|
---|
117 |
|
---|
118 | Image::ExifTool::Scalado - Read APP4 SCALADO metadata
|
---|
119 |
|
---|
120 | =head1 SYNOPSIS
|
---|
121 |
|
---|
122 | This module is loaded automatically by Image::ExifTool when required.
|
---|
123 |
|
---|
124 | =head1 DESCRIPTION
|
---|
125 |
|
---|
126 | This module contains definitions required by Image::ExifTool to read
|
---|
127 | metadata from the JPEG APP4 SCALADO segment.
|
---|
128 |
|
---|
129 | =head1 AUTHOR
|
---|
130 |
|
---|
131 | Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
|
---|
132 |
|
---|
133 | This library is free software; you can redistribute it and/or modify it
|
---|
134 | under the same terms as Perl itself.
|
---|
135 |
|
---|
136 | =head1 SEE ALSO
|
---|
137 |
|
---|
138 | L<Image::ExifTool::TagNames/Scalado Tags>,
|
---|
139 | L<Image::ExifTool(3pm)|Image::ExifTool>
|
---|
140 |
|
---|
141 | =cut
|
---|