# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../cthumb/png.patch
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
diff -ruN cthumb-4.2/cthumb.in cthumb-4.2-new/cthumb.in
--- cthumb-4.2/cthumb.in	2002-08-13 19:24:05.000000000 +0200
+++ cthumb-4.2-new/cthumb.in	2004-04-04 12:59:31.842021168 +0200
@@ -707,7 +707,7 @@
     my $pic = shift;
 
     # $pic =~ /^(.*?)(\.gif|\.jpg)?$/;
-    $pic =~ m#^(.*/)?([^/]+)\.(gif|tif+|jpe?g)$#i;
+    $pic =~ m#^(.*/)?([^/]+)\.(gif|tif+|jpe?g|png)$#i;
     # use thumb/ subdirectory if it already exists
     my $base = (defined($1))? $1 : '';
     if (-w ($base . "thumb")) {
@@ -742,6 +742,8 @@
   }
   for my $cmd ("djpeg", "pngtopnm", "giftopnm", "tifftopnm") {
     my $pnm = `$cmd "$name" `;
+    if ($pnm eq "") { print "not with $cmd ... "; }
+    else            { print "with $cmd ..."; } ;
     return $pnm unless $?;
   }
   return;
@@ -1069,14 +1071,14 @@
                 $pictureGeometry,
                 $pictureSize,
                 $pictureTitle,
-                $pictureStory,
-                $pictureTimestamp,
-                $albumURL,
-                $albumTitle,
-                $geometryLink,
-		$themePrefix);
-        }
-    }
+	$pictureStory,
+	$pictureTimestamp,
+	$albumURL,
+	$albumTitle,
+	$geometryLink,
+	$themePrefix);
+}
+}
 }
 
 # This function is responsible for generating html for a single image that
@@ -1715,7 +1717,7 @@
 
 	my $pnm = "";
 	if (!($pnm = &get_pnm($src))) {
-            die "Cannot scale image `$dest`.";
+            warn "Cannot scale image `$dest`, cthumb will fail!";
 	}
 	# make pnmscale shut up (version in redhat 7.2
 	# spits out stuff to stderr, even without -verbose, arggh)
@@ -1730,7 +1732,7 @@
 	    close PNMTOTHUMB;
 	    print "done.\n";
 	} else {
-            die "Cannot scale image `$dest`.";
+            warn "Cannot scale image `$dest`.";
 	}
     }
 
@@ -1766,6 +1768,17 @@
 	}
     }
 
+    if ($picname =~ /\.png$/i) {
+	open FILE, "pngtopnm \"$picname\" | pnmfile |" or
+	    return "";
+	$_ = <FILE>;
+	if (/^stdin:\s+PPM raw, (\d+) by (\d+)/) {
+	    $width = $1; $height = $2;
+	    close FILE;
+	    return "$width" . "x" . "$height";
+	}
+    }
+
     return "";
 }