diff options
Diffstat (limited to 'lib/gcstar/GCExport/GCExportBase.pm')
-rw-r--r-- | lib/gcstar/GCExport/GCExportBase.pm | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/gcstar/GCExport/GCExportBase.pm b/lib/gcstar/GCExport/GCExportBase.pm index fb23ec2..0c229d7 100644 --- a/lib/gcstar/GCExport/GCExportBase.pm +++ b/lib/gcstar/GCExport/GCExportBase.pm @@ -133,6 +133,29 @@ use GCExportImport; return $self->{options}->{parent}->getUniqueImageFileName($suffix, $title, $dir); } + sub createMiniature + { + my ($self, $source, $dest, $newHeight) = @_; + + $source =~ /.*?(\.[^.]*)$/; + my $suffix = $1; + my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($source); + my ($width, $height) = ($pixbuf->get_width, $pixbuf->get_height); + my $picWidth = $width * ($newHeight / $height); + $pixbuf = GCUtils::scaleMaxPixbuf($pixbuf, $picWidth, $newHeight, 1); + my $format; + if ($suffix =~ /png/i) + { + $format = 'png'; + } + else + { + $dest =~ s/\.[^.]*$/\.jpg/; + $format = 'jpeg'; + } + $pixbuf->save($dest, $format); + } + sub duplicatePicture { my ($self, $orig, $field, $dir, $title, $newHeight) = @_; @@ -157,21 +180,7 @@ use GCExportImport; my $picHeight = $self->getNewPictureHeight; if ($picHeight) { - my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($newPic); - my ($width, $height) = ($pixbuf->get_width, $pixbuf->get_height); - my $picWidth = $width * ($picHeight / $height); - $pixbuf = GCUtils::scaleMaxPixbuf($pixbuf, $picWidth, $picHeight, 1); - my $format; - if ($suffix =~ /png/i) - { - $format = 'png'; - } - else - { - $dest =~ s/\.[^.]*$/\.jpg/; - $format = 'jpeg'; - } - $pixbuf->save($dest, $format); + $self->createMiniature($newPic, $dest, $picHeight); } else { |