]> mj.ucw.cz Git - gallery.git/commitdiff
UCW::Partial support for PNG images
authorMartin Mares <mj@ucw.cz>
Mon, 31 Dec 2012 20:17:15 +0000 (21:17 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 20:14:17 +0000 (21:14 +0100)
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.

gal/FORMAT
gal/UCW/Gallery.pm
gal/UCW/Gallery/Web.pm
gal/UCW/Gallery/Web/HighSlide.pm
gal/bin/gal-cache
gal/bin/gal-gen

index 67118ec38e88f0bd81e8cf38e874b366f65bcc24..55ddd0daac9e39c5a26f485e283b9d5ae56b50cc 100644 (file)
@@ -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:
 
index 63e51b9f1fc76f6c0b01a38058f55e9ea96ab3a1..2773fa14626462f722c2460c46302593f2ec5c26 100644 (file)
@@ -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;
index dbf913a63de4858f97fbdb8ef1359cb08cbf4d47..af87ba5c9d7e109a16fce38c3770bf3f40ba8b42 100644 (file)
@@ -82,7 +82,7 @@ sub show_img($) {
        my $w = $m->{w};
        my $h = $m->{h};
        print "<h1>$t</h1>\n" if $t ne "";
-       my $img = $self->get('PhotoUrlPrefix') . $id . '.jpg';
+       my $img = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $id);
        print "<p class=large><img src='$img' width=$w height=$h alt='$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);
        }
index 901cdd138ee54fa4fc3595a7ba817bda12ff279b..d88cdd364beaff2bda5c3671735cbcb722b27dbf 100644 (file)
@@ -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 "<li><a$aid href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
        print "<img src='$thumb' width=$tw height=$th alt='Photo'$tit></a>\n";
 }
index 904b85e3e04c28c4a93463802b6456056151809b..f5792214c32986a8fda19b70d041a7baa041b44d 100755 (executable)
@@ -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";
 
index ce75896dbffa43e3ae84e8c7d6c146590efd52b0..f190bee132d2bde02af8dc87fec69a7fab5da751 100755 (executable)
@@ -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";