From: Martin Mares Date: Mon, 31 Dec 2012 20:17:15 +0000 (+0100) Subject: UCW::Partial support for PNG images X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=f9196be61e21826beb7c25cd324d0af74496f68a;p=gallery.git UCW::Partial support for PNG images Once they enter the photo repository, accompanied by correct format specification in the meta-data, they are thumbnailed and displayed properly. However, gal-scan and gal-gen do not handled them yet. --- diff --git a/gal/FORMAT b/gal/FORMAT index 67118ec..55ddd0d 100644 --- a/gal/FORMAT +++ b/gal/FORMAT @@ -24,6 +24,7 @@ $meta->{photo}->{$identifier} is a hash of: w width after scaling h height after scaling title photo title + fmt photo format (png/jpg; defaults to jpg) The rest is present in cache.meta only: diff --git a/gal/UCW/Gallery.pm b/gal/UCW/Gallery.pm index 63e51b9..2773fa1 100644 --- a/gal/UCW/Gallery.pm +++ b/gal/UCW/Gallery.pm @@ -155,4 +155,9 @@ sub thumb_fmt_to_size($$) { return ($tw, $th); } +sub photo_name($$$) { + my ($self, $photo_meta, $id) = @_; + return $id . '.' . ($photo_meta->{fmt} // 'jpg'); +} + 1; diff --git a/gal/UCW/Gallery/Web.pm b/gal/UCW/Gallery/Web.pm index dbf913a..af87ba5 100644 --- a/gal/UCW/Gallery/Web.pm +++ b/gal/UCW/Gallery/Web.pm @@ -82,7 +82,7 @@ sub show_img($) { my $w = $m->{w}; my $h = $m->{h}; print "

$t

\n" if $t ne ""; - my $img = $self->get('PhotoUrlPrefix') . $id . '.jpg'; + my $img = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $id); print "

$t\n"; $self->html_bot; @@ -109,11 +109,12 @@ sub show_list($) { my $meta = $self->{meta}; for my $idx (1..$self->{num_photos}) { my $id = $meta->{sequence}->[$idx-1]; + my $m = $meta->{photo}->{$id}; my $click_url; if ($self->get('WebImageSubpages')) { $click_url = "?i=$idx"; } else { - $click_url = $self->get('PhotoUrlPrefix') . "$id.jpg"; + $click_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $id); } $self->show_thumb($meta, $id, $click_url); } diff --git a/gal/UCW/Gallery/Web/HighSlide.pm b/gal/UCW/Gallery/Web/HighSlide.pm index 901cdd1..d88cdd3 100644 --- a/gal/UCW/Gallery/Web/HighSlide.pm +++ b/gal/UCW/Gallery/Web/HighSlide.pm @@ -60,7 +60,7 @@ sub show_thumb($) { # Highslide requires title either for all images, or for none my $tit = " title=\"$annot\""; my $aid = $self->{hs_thumb_counter}++ ? "" : " id=thumb1"; - my $photo_url = $self->get('PhotoUrlPrefix') . "$photo_id.jpg"; + my $photo_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $photo_id); print "

  • "; print "Photo\n"; } diff --git a/gal/bin/gal-cache b/gal/bin/gal-cache index 904b85e..f579221 100755 --- a/gal/bin/gal-cache +++ b/gal/bin/gal-cache @@ -53,7 +53,7 @@ for my $thumb_fmt (@{$gal->get('ThumbFormats')}) { print "\t$id: "; my $p = new Image::Magick; - my $photo = File::Spec->catfile($photo_dir, "$id.jpg"); + my $photo = File::Spec->catfile($photo_dir, $gal->photo_name($m, $id)); my $e; $e = $p->Read($photo) and die "Error reading $photo: $e"; diff --git a/gal/bin/gal-gen b/gal/bin/gal-gen index ce75896..f190bee 100755 --- a/gal/bin/gal-gen +++ b/gal/bin/gal-gen @@ -110,7 +110,7 @@ for my $f (@$orig_list) { $p->Resize(width=>$w, height=>$h); } - my $photo = File::Spec->catfile($photo_dir, $id . ".jpg"); + my $photo = File::Spec->catfile($photo_dir, $gal->photo_meta($m, $id)); my $tmp = "$photo.new"; $e = $p->Write($tmp) and die "Unable to write $tmp: $e"; rename $tmp, $photo or die "Cannot rename $tmp to $photo: $!\n";