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 |
|
---|
12 | package Image::ExifTool::PCX;
|
---|
13 |
|
---|
14 | use strict;
|
---|
15 | use vars qw($VERSION);
|
---|
16 | use 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
|
---|
84 | sub 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 |
|
---|
98 | 1; # end
|
---|
99 |
|
---|
100 | __END__
|
---|
101 |
|
---|
102 | =head1 NAME
|
---|
103 |
|
---|
104 | Image::ExifTool::PCX - Read metadata from PC Paintbrush files
|
---|
105 |
|
---|
106 | =head1 SYNOPSIS
|
---|
107 |
|
---|
108 | This module is used by Image::ExifTool
|
---|
109 |
|
---|
110 | =head1 DESCRIPTION
|
---|
111 |
|
---|
112 | This module contains routines required by Image::ExifTool to extract
|
---|
113 | information from PC Paintbrush (PCX) files.
|
---|
114 |
|
---|
115 | =head1 AUTHOR
|
---|
116 |
|
---|
117 | Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
|
---|
118 |
|
---|
119 | This library is free software; you can redistribute it and/or modify it
|
---|
120 | under 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 |
|
---|
134 | L<Image::ExifTool::TagNames/PCX Tags>,
|
---|
135 | L<Image::ExifTool(3pm)|Image::ExifTool>
|
---|
136 |
|
---|
137 | =cut
|
---|
138 |
|
---|