summaryrefslogtreecommitdiff
path: root/lib/gcstar/GCExport
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gcstar/GCExport')
-rw-r--r--lib/gcstar/GCExport/GCExportBase.pm39
-rw-r--r--lib/gcstar/GCExport/GCExportExternal.pm19
-rw-r--r--lib/gcstar/GCExport/GCExportHTML.pm2
3 files changed, 42 insertions, 18 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
{
diff --git a/lib/gcstar/GCExport/GCExportExternal.pm b/lib/gcstar/GCExport/GCExportExternal.pm
index d5c096c..2263387 100644
--- a/lib/gcstar/GCExport/GCExportExternal.pm
+++ b/lib/gcstar/GCExport/GCExportExternal.pm
@@ -45,6 +45,7 @@ use GCExport::GCExportBase;
bless ($self, $class);
$self->{useZip} = $self->checkOptionalModule('Archive::Zip');
+ $self->{covers} = {};
return $self;
}
@@ -57,10 +58,13 @@ use GCExport::GCExportBase;
sub transformPicturePath
{
my ($self, $path, $file, $item, $field) = @_;
- return $self->duplicatePicture($path,
+ my $newPath = $self->duplicatePicture($path,
$field,
$self->{imageDir},
$item->{$self->{model}->{commonFields}->{title}});
+ $self->{isCover}->{$newPath} = 1
+ if $self->{model}->{commonFields}->{cover} eq $field;
+ return $newPath;
}
sub process
@@ -123,8 +127,19 @@ use GCExport::GCExportBase;
my $zip = Archive::Zip->new();
$zip->addFile(basename($self->{fileName}));
$zip->addDirectory(basename($self->{imageDir}));
+ my $miniDir = $self->{imageDir}.'-mini';
+ mkdir $miniDir;
+ $zip->addDirectory(basename($miniDir));
my @images = glob $imagesSubDir.'/*';
- $zip->addFile($_) foreach @images;
+ foreach my $image(@images)
+ {
+ $zip->addFile($image);
+ my $imgFile = basename($image);
+ my $fullFileName = $self->{imageDir}."/$imgFile";
+ next if !$self->{isCover}->{$image};
+ $self->createMiniature($fullFileName, "$miniDir/$imgFile", 150);
+ $zip->addFile(basename($miniDir)."/$imgFile");
+ }
my $result = $zip->writeToFileNamed($outFile);
if ($result)
{
diff --git a/lib/gcstar/GCExport/GCExportHTML.pm b/lib/gcstar/GCExport/GCExportHTML.pm
index b083545..406039c 100644
--- a/lib/gcstar/GCExport/GCExportHTML.pm
+++ b/lib/gcstar/GCExport/GCExportHTML.pm
@@ -195,6 +195,7 @@ use GCExport::GCExportBase;
$parent->{options}->{modelFile}->set_sensitive($model eq 'UseFile');
$parent->{fieldsSelection}->set_sensitive($self->{isGeneric}->{$model})
if $parent->{fieldsSelection};
+ $self->{wantsFieldsSelection} = $self->{isGeneric}->{$model};
}
sub preview
@@ -240,7 +241,6 @@ use GCExport::GCExportBase;
{
my $self = shift;
return 1;
- return $self->{genericAdded} || $self->{genericModels};
}
sub wantsImagesSelection