source: main/trunk/greenstone2/perllib/cpan/Image/ExifTool/PCX.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.7 KB
Line 
1#------------------------------------------------------------------------------
2# File: PCX.pm
3#
4# Description: Read metadata from PC Paintbrush files
5#
6# Revisions: 2018/12/12 - P. Harvey Created
7#
8# References: 1) http://qzx.com/pc-gpe/pcx.txt
9# 2) https://www.fileformat.info/format/pcx/corion.htm
10#------------------------------------------------------------------------------
11
12package Image::ExifTool::PCX;
13
14use strict;
15use vars qw($VERSION);
16use Image::ExifTool qw(:DataAccess :Utils);
17
18$VERSION = '1.00';
19
20# PCX info
21%Image::ExifTool::PCX::Main = (
22 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
23 GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
24 NOTES => 'Tags extracted from PC Paintbrush images.',
25 DATAMEMBER => [ 0x04, 0x05 ],
26 0x00 => {
27 Name => 'Manufacturer',
28 PrintConv => { 10 => 'ZSoft' },
29 },
30 0x01 => {
31 Name => 'Software',
32 PrintConv => {
33 0 => 'PC Paintbrush 2.5',
34 2 => 'PC Paintbrush 2.8 (with palette)',
35 3 => 'PC Paintbrush 2.8 (without palette)',
36 4 => 'PC Paintbrush for Windows',
37 5 => 'PC Paintbrush 3.0+',
38 },
39 },
40 0x02 => { Name => 'Encoding', PrintConv => { 1 => 'RLE' } },
41 0x03 => 'BitsPerPixel',
42 0x04 => {
43 Name => 'LeftMargin',
44 Format => 'int16u',
45 RawConv => '$$self{LeftMargin} = $val',
46 },
47 0x06 => {
48 Name => 'TopMargin',
49 Format => 'int16u',
50 RawConv => '$$self{TopMargin} = $val',
51 },
52 0x08 => {
53 Name => 'ImageWidth',
54 Format => 'int16u',
55 Notes => 'adjusted for LeftMargin',
56 ValueConv => '$val - $$self{LeftMargin} + 1',
57 },
58 0x0a => {
59 Name => 'ImageHeight',
60 Format => 'int16u',
61 Notes => 'adjusted for TopMargin',
62 ValueConv => '$val - $$self{TopMargin} + 1',
63 },
64 0x0c => 'XResolution',
65 0x0e => 'YResolution',
66 0x41 => 'ColorPlanes',
67 0x42 => { Name => 'BytesPerLine', Format => 'int16u' },
68 0x44 => {
69 Name => 'ColorMode',
70 PrintConv => {
71 0 => 'n/a',
72 1 => 'Color Palette',
73 2 => 'Grayscale',
74 },
75 },
76 0x46 => { Name => 'ScreenWidth', Format => 'int16u', RawConv => '$val or undef' },
77 0x48 => { Name => 'ScreenHeight', Format => 'int16u', RawConv => '$val or undef' },
78);
79
80#------------------------------------------------------------------------------
81# Extract information from a PCX image
82# Inputs: 0) ExifTool object reference, 1) dirInfo reference
83# Returns: 1 on success, 0 if this wasn't a valid PCX file
84sub ProcessPCX($$)
85{
86 my ($et, $dirInfo) = @_;
87 my $raf = $$dirInfo{RAF};
88 my $buff;
89 return 0 unless $raf->Read($buff, 0x50) == 0x50 and
90 $buff =~ /^\x0a[\0-\x05]\x01[\x01\x02\x04\x08].{64}[\0-\x02]/s;
91 SetByteOrder('II');
92 $et->SetFileType();
93 my %dirInfo = ( DirName => 'PCX', DataPt => \$buff );
94 my $tagTablePtr = GetTagTable('Image::ExifTool::PCX::Main');
95 return $et->ProcessBinaryData(\%dirInfo, $tagTablePtr);
96}
97
981; # end
99
100__END__
101
102=head1 NAME
103
104Image::ExifTool::PCX - Read metadata from PC Paintbrush files
105
106=head1 SYNOPSIS
107
108This module is used by Image::ExifTool
109
110=head1 DESCRIPTION
111
112This module contains routines required by Image::ExifTool to extract
113information from PC Paintbrush (PCX) files.
114
115=head1 AUTHOR
116
117Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
118
119This library is free software; you can redistribute it and/or modify it
120under the same terms as Perl itself.
121
122=head1 REFERENCES
123
124=over 4
125
126=item L<http://qzx.com/pc-gpe/pcx.txt>
127
128=item L<https://www.fileformat.info/format/pcx/corion.htm>
129
130=back
131
132=head1 SEE ALSO
133
134L<Image::ExifTool::TagNames/PCX Tags>,
135L<Image::ExifTool(3pm)|Image::ExifTool>
136
137=cut
138
Note: See TracBrowser for help on using the repository browser.