source: main/trunk/greenstone2/perllib/cpan/Image/ExifTool/ZISRAW.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.6 KB
Line 
1#------------------------------------------------------------------------------
2# File: ZISRAW.pm
3#
4# Description: Read ZISRAW (CZI) meta information
5#
6# Revisions: 2020-08-07 - P. Harvey Created
7#
8# References: 1) https://www.zeiss.com/microscopy/us/products/microscope-software/zen/czi.html
9#------------------------------------------------------------------------------
10
11package Image::ExifTool::ZISRAW;
12
13use strict;
14use vars qw($VERSION);
15use Image::ExifTool qw(:DataAccess :Utils);
16
17$VERSION = '1.00';
18
19%Image::ExifTool::ZISRAW::Main = (
20 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
21 GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
22 NOTES => q{
23 As well as the header information listed below, ExifTool also extracts the
24 top-level XML-based metadata from Zeiss Integrated Software RAW (ZISRAW) CZI
25 files.
26 },
27 0x20 => {
28 Name => 'ZISRAWVersion',
29 Format => 'int32u[2]',
30 PrintConv => '$val =~ tr/ /./; $val',
31 },
32 0x30 => {
33 Name => 'PrimaryFileGUID',
34 Format => 'undef[16]',
35 ValueConv => 'unpack("H*",$val)',
36 },
37 0x40 => {
38 Name => 'FileGUID',
39 Format => 'undef[16]',
40 ValueConv => 'unpack("H*",$val)',
41 },
42);
43
44#------------------------------------------------------------------------------
45# Extract metadata from a ZISRAW (CZI) image
46# Inputs: 0) ExifTool object reference, 1) dirInfo reference
47# Returns: 1 on success, 0 if this wasn't a valid CZI file
48sub ProcessCZI($$)
49{
50 my ($et, $dirInfo) = @_;
51 my $raf = $$dirInfo{RAF};
52 my ($buff, $tagTablePtr);
53
54 # verify this is a valid CZI file
55 return 0 unless $raf->Read($buff, 100) == 100;
56 return 0 unless $buff =~ /^ZISRAWFILE\0{6}/;
57 $et->SetFileType();
58 SetByteOrder('II');
59 my %dirInfo = (
60 DataPt => \$buff,
61 DirStart => 0,
62 DirLen => length($buff),
63 );
64 $tagTablePtr = GetTagTable('Image::ExifTool::ZISRAW::Main');
65 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
66
67 # read the metadata section
68 my $pos = Get64u(\$buff, 92) or return 1;
69 $raf->Seek($pos, 0) or $et->Warn('Error seeking to metadata'), return 0;
70 $raf->Read($buff, 288) == 288 or $et->Warn('Error reading metadata header'), return 0;
71 $buff =~ /^ZISRAWMETADATA\0\0/ or $et->Warn('Invalid metadata header'), return 0;
72 my $len = Get32u(\$buff, 32);
73 $len < 200000000 or $et->Warn('Metadata section too large. Ignoring'), return 0;
74 $raf->Read($buff, $len) or $et->Warn('Error reading XML metadata'), return 0;
75 $et->FoundTag('XML', $buff); # extract as a block
76 $tagTablePtr = GetTagTable('Image::ExifTool::XMP::XML');
77 $dirInfo{DirLen} = length $buff;
78 # shorten tag names somewhat by removing 'ImageDocumentMetadata' prefix from all
79 $$et{XmpIgnoreProps} = [ 'ImageDocument', 'Metadata' ];
80 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
81
82 return 1;
83}
84
851; # end
86
87__END__
88
89=head1 NAME
90
91Image::ExifTool::ZISRAW - Read ZISRAW (CZI) meta information
92
93=head1 SYNOPSIS
94
95This module is used by Image::ExifTool
96
97=head1 DESCRIPTION
98
99This module contains definitions required by Image::ExifTool to read
100metadata from Zeiss Integrated Software RAW (ZISRAW) CZI files.
101
102=head1 AUTHOR
103
104Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
105
106This library is free software; you can redistribute it and/or modify it
107under the same terms as Perl itself.
108
109=head1 REFERENCES
110
111=over 4
112
113=item L<https://www.zeiss.com/microscopy/us/products/microscope-software/zen/czi.html>
114
115=back
116
117=head1 SEE ALSO
118
119L<Image::ExifTool::TagNames/ZISRAW Tags>,
120L<Image::ExifTool(3pm)|Image::ExifTool>
121
122=cut
123
Note: See TracBrowser for help on using the repository browser.