--- Gallery.pm	Sun Feb  9 01:34:11 2003
+++ Apache/Gallery.pm	Sun Feb  9 01:51:03 2003
@@ -206,7 +206,10 @@
 
 					$tpl->assign(FILEURL => uri_escape($fileurl, $escape_rule));
 					$tpl->assign(FILE    => $file);
-					$tpl->assign(DATE    => $imageinfo->{DateTimeOriginal} ? $imageinfo->{DateTimeOriginal} : ''); # should this really be a stat of the file instead of ''?
+					$tpl->assign(DATE    => $imageinfo->{DateTimeOriginal} ? $imageinfo->{DateTimeOriginal} : $imageinfo->{FileDateTime});
+					
+					$tpl->assign(COMMENT => $imageinfo->{Comment} ? ext_multi_comments( $imageinfo ) : '');
+					$tpl->assign(SIZE    => $imageinfo->{FileSize} ? $imageinfo->{FileSize} : '');
 					$tpl->assign(SRC     => uri_escape($uri."/.cache/$cached", $escape_rule));
 
 					$tpl->parse(FILES => '.picture');
@@ -389,6 +392,10 @@
 				$foundcomment = 1;
 		    $tpl->assign(COMMENT => $comment_ref->{COMMENT} . '<br>') if $comment_ref->{COMMENT};
 		    $tpl->assign(TITLE => $comment_ref->{TITLE}) if $comment_ref->{TITLE};
+		} elsif ( $r->dir_config('GalleryUseHeaderComments') ) {
+		    my $comment = ext_multi_comments( $imageinfo );
+		    $foundcomment = $comment ne '';
+		    $tpl->assign( COMMENT => $comment );
 		} else {
 		    $tpl->assign(COMMENT => '');
 		}
@@ -481,6 +488,20 @@
 	return OK;
 }
 
+sub ext_multi_comments {
+    my ( $imageinfo ) = @_;
+
+    my $multi_comment = '';
+    if( exists $imageinfo->{'Comment'} ){
+	$multi_comment = $imageinfo->{'Comment'};
+	if( ref $multi_comment eq 'ARRAY' ){
+	    $multi_comment = join "<br>\n", @$multi_comment;
+	}
+    }
+    return $multi_comment;
+}
+
+
 sub cache_dir {
 
 	my ($r, $strip_filename) = @_;
@@ -637,6 +658,17 @@
 	return ($width, $height);
 }
 
+sub FilterSize{ # input: size returned by -s
+  my($size) = @_;
+  my @scale = ("Bytes","KB","MB","GB","TB","PB");
+  my $ord = 0;
+  if($size > 0){
+    $ord = int(log($size)/log(1024));
+  }
+  $size = sprintf("%.2f",$size/(1024 ** $ord));
+  return "$size ".$scale[$ord];
+}
+
 sub get_imageinfo {
 	my ($r, $file, $type, $width, $height) = @_;
 	my $imageinfo = {};
@@ -656,6 +688,11 @@
 		$imageinfo = image_info($file);
 	}
 
+	$imageinfo->{FileSize} = FilterSize( -s $file );
+
+	my $stat = stat( $file );
+	$imageinfo->{FileDateTime} = localtime( $stat->mtime );
+
 	unless (defined($imageinfo->{width}) and defined($imageinfo->{height})) {
 		$imageinfo->{width} = $width;
 		$imageinfo->{height} = $height;
@@ -1003,6 +1040,14 @@
 With this option you can configure which intervals can be selected for
 a slideshow. The default is '3 5 10 15 30'
 
+=item B<GalleryUseHeaderComments>
+
+This will use the comments field of the image if there are any present. 
+Often times this is un-wanted, as programs like Photoshop like to put 
+"created by..." advertisements in that field.
+
+Set to 1 or 0, default is 0
+
 =back
 
 =head1 FEATURES
@@ -1037,6 +1082,9 @@
 	TITLE: This is the new title of the page
 	And this is the comment.<br>
 	And this is line two of the comment.
+
+Comments can also be put inside the image itself. See 
+B<GalleryUseHeaderComments>.
 
 =back
 
