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