thumbnail-extractor.pl
- this will extract a thumbnail inside the exif metadata embedded in the jpeg file.
- we use this technique to help speed up generating a thumbnail image by simply getting it instead of making a thumbnail yourself
- this is for demonstration purposes only
- written in windows using activeperl
#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Image::ExifTool qw(ImageInfo);
my $exifTool = Image::ExifTool->new();
$exifTool->Options(Binary => 1);
my $window = Gtk2::Window->new();
$window->signal_connect('destroy'=>sub{
Gtk2->main_quit();
});
my $image = Gtk2::Image->new();
$image->set('pixbuf'=>load_thumbnail("c:\\test.jpg"));
$window->add($image);
$window->show_all();
Gtk2->main();
sub load_thumbnail {
my ($file) = @_;
my $info = $exifTool->ImageInfo($file, 'thumbnailimage');
my $data = ${$$info{ThumbnailImage}};
my $loader = Gtk2::Gdk::PixbufLoader->new();
$loader->write($data);
$loader->close();
my $pixbuf = $loader->get_pixbuf();
return $pixbuf;
}
No comments:
Post a Comment