~ubuntu-branches/ubuntu/karmic/libimage-exiftool-perl/karmic

« back to all changes in this revision

Viewing changes to lib/Image/ExifTool/FujiFilm.pm

  • Committer: Bazaar Package Importer
  • Author(s): Mari Wang
  • Date: 2008-02-04 20:32:53 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080204203253-mpbal8trlfe1fz5d
Tags: 7.00-1
* Upload of new production release (Closes: #456430)
* Added Recommends: libcompress-zlib-perl (Closes: #435589)
* Package now includes iptc2xmp.args and xmp2iptc.args, they are put
  into /usr/share/libimage-exiftool/ (Closes: #436100)
* Updated standards-version (3.7.2 -> 3.7.3). No changes needed.
* Lots of updates and bugfixes compared to last debian version
  (6.90).  See the Changes file for details
* Upload sponsored by Petter Reinholdtsen

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
# References:   1) http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
9
9
#               2) http://homepage3.nifty.com/kamisaka/makernote/makernote_fuji.htm
10
10
#               3) Michael Meissner private communication
 
11
#               4) Paul Samuelson private communication (S5)
 
12
#               5) http://www.cybercom.net/~dcoffin/dcraw/
11
13
#------------------------------------------------------------------------------
12
14
 
13
15
package Image::ExifTool::FujiFilm;
14
16
 
15
17
use strict;
16
18
use vars qw($VERSION);
17
 
use Image::ExifTool qw(:DataAccess);
 
19
use Image::ExifTool qw(:DataAccess :Utils);
18
20
use Image::ExifTool::Exif;
19
21
 
20
 
$VERSION = '1.12';
 
22
$VERSION = '1.14';
21
23
 
22
24
%Image::ExifTool::FujiFilm::Main = (
23
25
    WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
72
74
            0x301 => 'Day White Fluorescent',
73
75
            0x302 => 'White Fluorescent',
74
76
            0x400 => 'Incandescent',
 
77
            0x500 => 'Flash', #4
75
78
            0xf00 => 'Custom',
 
79
            0xff0 => 'Kelvin', #4
76
80
        },
77
81
    },
78
82
    0x1003 => {
96
100
            0x200 => 'Low',
97
101
        },
98
102
    },
 
103
    0x1005 => { #4
 
104
        Name => 'ColorTemperature',
 
105
        Writable => 'int16u',
 
106
    },
99
107
    0x1010 => {
100
108
        Name => 'FujiFlashMode',
101
109
        Writable => 'int16u',
286
294
    },
287
295
);
288
296
 
 
297
# tags in RAF images (ref 5)
 
298
%Image::ExifTool::FujiFilm::RAF = (
 
299
    GROUPS => { 0 => 'RAF', 1 => 'RAF', 2 => 'Image' },
 
300
    NOTES => 'Tags extracted from FujiFilm RAF-format information.',
 
301
    0x100 => {
 
302
        Name => 'RawImageFullSize',
 
303
        Format => 'int16u',
 
304
        Groups => { 1 => 'RAF2' }, # (so RAF2 shows up in family 1 list)
 
305
        Count => 2,
 
306
        Notes => 'including borders',
 
307
        ValueConv => 'my @v=reverse split(" ",$val);"@v"',
 
308
        PrintConv => '$val=~tr/ /x/; $val',
 
309
    },
 
310
    0x121 => [
 
311
        {
 
312
            Name => 'RawImageSize',
 
313
            Condition => '$$self{CameraModel} eq "FinePixS2Pro"',
 
314
            Format => 'int16u',
 
315
            Count => 2,
 
316
            ValueConv => q{
 
317
                my @v=split(" ",$val);
 
318
                $v[0]*=2, $v[1]/=2;
 
319
                return "@v";
 
320
            },
 
321
            PrintConv => '$val=~tr/ /x/; $val',
 
322
        },
 
323
        {
 
324
            Name => 'RawImageSize',
 
325
            Format => 'int16u',
 
326
            Count => 2,
 
327
            # values are height then width, adjusted for the layout
 
328
            ValueConv => q{
 
329
                my @v=reverse split(" ",$val);
 
330
                $$self{FujiLayout} and $v[0]/=2, $v[1]*=2;
 
331
                return "@v";
 
332
            },
 
333
            PrintConv => '$val=~tr/ /x/; $val',
 
334
        },
 
335
    ],
 
336
    0x130 => {
 
337
        Name => 'FujiLayout',
 
338
        Format => 'int8u',
 
339
        RawConv => q{
 
340
            my ($v) = split ' ', $val;
 
341
            $$self{FujiLayout} = $v & 0x80 ? 1 : 0;
 
342
            return $val;
 
343
        },
 
344
    },
 
345
    0x2ff0 => {
 
346
        Name => 'WB_GRGBLevels',
 
347
        Format => 'int16u',
 
348
        Count => 4,
 
349
    },
 
350
);
 
351
 
 
352
#------------------------------------------------------------------------------
 
353
# get information from FujiFilm RAF directory
 
354
# Inputs: 0) ExifTool object reference, 1) dirInfo reference, 2) tag table ref
 
355
# Returns: 1 if this was a valid FujiFilm directory
 
356
sub ProcessFujiDir($$$)
 
357
{
 
358
    my ($exifTool, $dirInfo, $tagTablePtr) = @_;
 
359
    my $raf = $$dirInfo{RAF};
 
360
    my $offset = $$dirInfo{DirStart};
 
361
    $raf->Seek($offset, 0) or return 0;
 
362
    my $buff;
 
363
    $raf->Read($buff, 4) or return 0;
 
364
    my $entries = unpack 'N', $buff;
 
365
    $entries < 256 or return 0;
 
366
    SetByteOrder('MM');
 
367
    while ($entries--) {
 
368
        $raf->Read($buff,4) or return 0;
 
369
        my ($tag, $len) = unpack 'nn', $buff;
 
370
        my ($val, $vbuf);
 
371
        $raf->Read($vbuf, $len) or return 0;
 
372
        my $tagInfo = $exifTool->GetTagInfo($tagTablePtr, $tag);
 
373
        if ($tagInfo and $$tagInfo{Format}) {
 
374
            $val = ReadValue(\$vbuf, 0, $$tagInfo{Format}, $$tagInfo{Count}, $len);
 
375
            next unless defined $val;
 
376
        } else {
 
377
            $val = \$vbuf;
 
378
        }
 
379
        $exifTool->HandleTag($tagTablePtr, $tag, $val);
 
380
    }
 
381
    return 1;
 
382
}
 
383
 
289
384
#------------------------------------------------------------------------------
290
385
# get information from FujiFilm RAW file
291
386
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
293
388
sub ProcessRAF($$)
294
389
{
295
390
    my ($exifTool, $dirInfo) = @_;
296
 
    my $buff;
 
391
    my ($buff, $warn);
 
392
 
297
393
    my $raf = $$dirInfo{RAF};
298
 
    $raf->Read($buff,8) == 8    or return 0;
299
 
    $buff eq 'FUJIFILM'         or return 0;
300
 
    $raf->Seek(84, 0)           or return 0;
301
 
    $raf->Read($buff, 4) == 4   or return 0;
302
 
    SetByteOrder('MM');
303
 
    my $base = Get32u(\$buff, 0) + 12;
 
394
    $raf->Read($buff,8) == 8        or return 0;
 
395
    $buff eq 'FUJIFILM'             or return 0;
 
396
    $raf->Seek(84, 0)               or return 0;
 
397
    $raf->Read($buff, 8) == 8       or return 0;
 
398
    my ($pos, $len) = unpack('NN', $buff);
 
399
    $pos & 0x8000                  and return 0;
 
400
    $raf->Seek($pos, 0)             or return 0;
 
401
    $raf->Read($buff, $len) == $len or return 0;
304
402
    my %dirInfo = (
305
403
        Parent => 'RAF',
306
 
        RAF    => $raf,
307
 
        Base   => $base,
 
404
        RAF    => new File::RandomAccess(\$buff),
308
405
    );
309
 
    return $exifTool->ProcessTIFF(\%dirInfo);
 
406
    $$exifTool{BASE} += $pos;
 
407
    my $rtnVal = $exifTool->ProcessJPEG(\%dirInfo);
 
408
    $$exifTool{BASE} -= $pos;
 
409
    $exifTool->FoundTag('PreviewImage', \$buff) if $rtnVal;
 
410
 
 
411
    if ($raf->Seek(92, 0) and $raf->Read($buff, 4)) {
 
412
        my $tagTablePtr = GetTagTable('Image::ExifTool::FujiFilm::RAF');
 
413
        %dirInfo = (
 
414
            RAF => $raf,
 
415
            DirStart => unpack('N', $buff),
 
416
        );
 
417
        $$exifTool{SET_GROUP1} = 'RAF';
 
418
        ProcessFujiDir($exifTool, \%dirInfo, $tagTablePtr) or $warn = 1;
 
419
    
 
420
        # extract information from 2nd image if available
 
421
        if ($pos > 120) {
 
422
            $raf->Seek(120, 0) or return 0;
 
423
            $raf->Read($buff, 4) or return 0;
 
424
            my $start = unpack('N',$buff);
 
425
            if ($start) {
 
426
                $$dirInfo{DirStart} = $start;
 
427
                $$exifTool{SET_GROUP1} = 'RAF2';
 
428
                ProcessFujiDir($exifTool, \%dirInfo, $tagTablePtr) or $warn = 1;
 
429
            }
 
430
        }
 
431
        delete $$exifTool{SET_GROUP1};
 
432
    } else {
 
433
        $warn = 1;
 
434
    }
 
435
    $warn and $exifTool->Warn('Possibly corrupt RAF information');
 
436
 
 
437
    return $rtnVal;
310
438
}
311
439
 
312
440
1; # end
340
468
 
341
469
=item L<http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html>
342
470
 
 
471
=item L<http://homepage3.nifty.com/kamisaka/makernote/makernote_fuji.htm>
 
472
 
 
473
=item L<http://www.cybercom.net/~dcoffin/dcraw/>
 
474
 
343
475
=item (...plus testing with my own FinePix 2400 Zoom)
344
476
 
345
477
=back
347
479
=head1 ACKNOWLEDGEMENTS
348
480
 
349
481
Thanks to Michael Meissner for decoding some new PictureMode and
350
 
AutoBracketing values.
 
482
AutoBracketing values, and to Paul Samuelson for decoding some WhiteBalance
 
483
values and the ColorTemperature tag.
351
484
 
352
485
=head1 SEE ALSO
353
486