$VERSION
=
'1.07'
;
%Image::ExifTool::MIFF::Main
= (
GROUPS
=> {
2
=>
'Image'
},
NOTES
=>
q{
The MIFF (Magick Image File Format) format allows aribrary tag names to be
used. Only the standard tag names are listed below, however ExifTool will
decode any tags found in the image.
}
,
'background-color'
=>
'BackgroundColor'
,
'blue-primary'
=>
'BluePrimary'
,
'border-color'
=>
'BorderColor'
,
'matt-color'
=>
'MattColor'
,
class
=>
'Class'
,
colors
=>
'Colors'
,
colorspace
=>
'ColorSpace'
,
columns
=>
'ImageWidth'
,
compression
=>
'Compression'
,
delay
=>
'Delay'
,
depth
=>
'Depth'
,
dispose
=>
'Dispose'
,
gamma
=>
'Gamma'
,
'green-primary'
=>
'GreenPrimary'
,
id
=>
'ID'
,
iterations
=>
'Iterations'
,
label
=>
'Label'
,
matte
=>
'Matte'
,
montage
=>
'Montage'
,
packets
=>
'Packets'
,
page
=>
'Page'
,
'profile-APP1'
=> [
{
Name
=>
'APP1_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::Exif::Main'
,
},
},
{
Name
=>
'APP1_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::XMP::Main'
,
},
},
],
'profile-exif'
=> {
Name
=>
'EXIF_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::Exif::Main'
,
},
},
'profile-icc'
=> {
Name
=>
'ICC_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::ICC_Profile::Main'
,
},
},
'profile-iptc'
=> {
Name
=>
'IPTC_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::Photoshop::Main'
,
},
},
'profile-xmp'
=> {
Name
=>
'XMP_Profile'
,
SubDirectory
=> {
TagTable
=>
'Image::ExifTool::XMP::Main'
,
},
},
'red-primary'
=>
'RedPrimary'
,
'rendering-intent'
=>
'RenderingIntent'
,
resolution
=>
'Resolution'
,
rows
=>
'ImageHeight'
,
scene
=>
'Scene'
,
signature
=>
'Signature'
,
units
=>
'Units'
,
'white-point'
=>
'WhitePoint'
,
);
sub
ProcessMIFF($$)
{
my
(
$et
,
$dirInfo
) =
@_
;
my
$raf
=
$$dirInfo
{RAF};
my
$verbose
=
$$et
{OPTIONS}{Verbose};
my
(
$hdr
,
$buff
);
return
0
unless
$raf
->Read(
$hdr
, 14) == 14;
return
0
unless
$hdr
eq
'id=ImageMagick'
;
$et
->SetFileType();
local
$/ =
":\x1a"
;
my
$mode
=
''
;
my
@profiles
;
if
(
$raf
->ReadLine(
$buff
)) {
chomp
$buff
;
my
$tagTablePtr
= GetTagTable(
'Image::ExifTool::MIFF::Main'
);
my
@entries
=
split
' '
,
$buff
;
unshift
@entries
,
$hdr
;
my
(
$tag
,
$val
);
foreach
(
@entries
) {
if
(
$mode
eq
'com'
) {
$mode
=
''
if
/\}$/;
next
;
}
elsif
(/^\{/) {
$mode
=
'com'
;
next
;
}
if
(
$mode
eq
'val'
) {
$val
.=
" $_"
;
next
unless
/\}$/;
$mode
=
''
;
$val
=~ s/(^\{|\}$)//g;
}
elsif
(/(.+)=(.+)/) {
(
$tag
,
$val
) = ($1, $2);
if
(
$val
=~ /^\{/) {
$mode
=
'val'
;
next
;
}
}
elsif
(/^:/) {
last
;
}
else
{
$et
->Warn(
'Unrecognized MIFF data'
);
last
;
}
my
$tagInfo
=
$et
->GetTagInfo(
$tagTablePtr
,
$tag
);
unless
(
$tagInfo
) {
$tagInfo
= {
Name
=>
$tag
};
AddTagToTable(
$tagTablePtr
,
$tag
,
$tagInfo
);
}
$verbose
and
$et
->VerboseInfo(
$tag
,
$tagInfo
,
Table
=>
$tagTablePtr
,
DataPt
=> \
$val
,
);
if
(
$tag
=~ /^profile-(.*)/) {
push
@profiles
, [$1,
$val
];
}
else
{
$et
->FoundTag(
$tagInfo
,
$val
);
}
}
}
foreach
(
@profiles
) {
my
(
$type
,
$len
) = @{
$_
};
unless
(
$len
=~ /^\d+$/) {
$et
->Warn(
"Invalid length for $type profile"
);
last
;
}
unless
(
$raf
->Read(
$buff
,
$len
) ==
$len
) {
$et
->Warn(
"Error reading $type profile ($len bytes)"
);
next
;
}
my
$processed
= 0;
my
%dirInfo
= (
Parent
=>
'PNG'
,
DataPt
=> \
$buff
,
DataPos
=>
$raf
->Tell() -
$len
,
DataLen
=>
$len
,
DirStart
=> 0,
DirLen
=>
$len
,
);
if
(
$type
eq
'icc'
) {
my
$tagTablePtr
= GetTagTable(
'Image::ExifTool::ICC_Profile::Main'
);
$processed
=
$et
->ProcessDirectory(\
%dirInfo
,
$tagTablePtr
);
}
elsif
(
$type
eq
'iptc'
) {
if
(
$buff
=~ /^8BIM/) {
my
$tagTablePtr
= GetTagTable(
'Image::ExifTool::Photoshop::Main'
);
$processed
=
$et
->ProcessDirectory(\
%dirInfo
,
$tagTablePtr
);
}
}
elsif
(
$type
eq
'APP1'
or
$type
eq
'exif'
or
$type
eq
'xmp'
) {
if
(
$buff
=~ /^
$Image::ExifTool::exifAPP1hdr
/) {
my
$hdrLen
=
length
(
$Image::ExifTool::exifAPP1hdr
);
$dirInfo
{DirStart} +=
$hdrLen
;
$dirInfo
{DirLen} -=
$hdrLen
;
$dirInfo
{Base} = 12;
$processed
=
$et
->ProcessTIFF(\
%dirInfo
);
}
elsif
(
$buff
=~ /^
$Image::ExifTool::xmpAPP1hdr
/) {
my
$hdrLen
=
length
(
$Image::ExifTool::xmpAPP1hdr
);
my
$tagTablePtr
= GetTagTable(
'Image::ExifTool::XMP::Main'
);
$dirInfo
{DirStart} +=
$hdrLen
;
$dirInfo
{DirLen} -=
$hdrLen
;
$processed
=
$et
->ProcessDirectory(\
%dirInfo
,
$tagTablePtr
);
}
}
unless
(
$processed
) {
$et
->Warn(
"Unknown MIFF $type profile data"
);
if
(
$verbose
) {
$et
->VerboseDir(
$type
, 0,
$len
);
$et
->VerboseDump(\
$buff
);
}
}
}
return
1;
}
1;