Thumbnail size same width

italjet

Joined: 2003-03-12
Posts: 12
Posted: Wed, 2004-02-25 00:37

Hello again

I was searching trough forums to find the answer but didn't find it. So here's the thing:
Once there was a way to make thumbnails the same width, so you could put them in 1 column and the width of all thumbs was the same. That hack worked in 1.3.3 and I remember that I tried it in 1.4.something and it returned an error. Is there some way to do it? I've seen something similar in your gallery.

Thanks, Luka

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Thu, 2004-02-26 04:19

i wouldn't mind knowing the answer to this as well.

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Thu, 2004-02-26 12:32

italjet.

have you still got a copy of that hack? I wouldn't mind having a look...

otherwise... who's the best person in the forum ask?

Uniform thumb widths look better in single columns, which is the layout I'm trying to acheive.

Are uniform widths a gallery 2 thing? I might jsut jump the gun if they are...

 
italjet

Joined: 2003-03-12
Posts: 12
Posted: Fri, 2004-02-27 13:40

Hey

Yeah well I do have a copy of that in some old test gallery. But I don't think it matters. I tried something else. I use ImageMagick. So the tool runs from command line and it has some switches. So I went trough IM help and figured that it uses size like 120x120, but both values are the same. This is done trough util.php

So I changed some of the code. I know, if you do this it's not so dynamic anymore but it works.

                case "ImageMagick":
                        $src = fs_import_filename($src);
                        $out = fs_import_filename($out);
                        /* Preserve comment, EXIF data if a JPEG if $keepProfiles is set. */
                        $err = exec_wrapper(ImCmd('convert', "-quality $quality "
                                        . ($target ? "-size ${target}x${target} " : '')
                                        . ($keepProfiles ? ' ' : ' +profile \'*\' ')
                                        . $src
                                        . ($target ? " -geometry ${target}x200 " : '')         
                                        . $out));
                        break;

Ok, it worked, but the problem was that I set the resized image to 800x800 and now it is limited by 200. It's not much of a problem for me because I resize all images before I upload and it doesn't touch them... so it works for me.

But there is another way

I have set my thumb size to be 120x120, and edited util.php, so width of thumbnails will always be 120. Since it is limited by that number I raised the other number to 800. Why? Because I use 800x800 for resized images.
So it goes like this. When u're creating thumbnails your size is 120x800 and when u're creating resized images your size is 800x800. That works for me. It can probably be done smoother, but at this time I'm not getting into it since I'm not a php guru (actually I don't know shit about it). So the final code is

                        break;
                case "ImageMagick":
                        $src = fs_import_filename($src);
                        $out = fs_import_filename($out);
                        /* Preserve comment, EXIF data if a JPEG if $keepProfiles is set. */
                        $err = exec_wrapper(ImCmd('convert', "-quality $quality "
                                        . ($target ? "-size ${target}x${target} " : '')
                                        . ($keepProfiles ? ' ' : ' +profile \'*\' ')
                                        . $src
                                        . ($target ? " -geometry ${target}x800 " : '')
                                        . $out));

Thats it for now, there is 50cm of snow outside (I'm from Ljubljana, Slovenia) so I have to go dig out my car and go to school.

I hope it helps, I'll try to do it better later.

Have a nice weekend (I know I will hehe).

Luka

 
italjet

Joined: 2003-03-12
Posts: 12
Posted: Fri, 2004-02-27 13:45

hdotnet,

Yeah I probably want the same layout as you, and I'm working on it. Keep me posted of your progress, so we can do it faster.

Luka

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Mon, 2004-03-08 19:27

haven't had a chance to try italjet's hack yet... but I've come across this post...

http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=4512&highlight=thumbnail+width

same idea

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Mon, 2004-03-08 23:38

just got a fixed thumbnail width of 150px using a fresh install using ImageMagick

installed as normal
open up util.php, search for Geomotry
should take you to the compress_image function...
edit as per the comments in the code below:

function compress_image($src, $out, $target, $quality, $keepProfiles=false) {
	global $gallery;

	if ($target === 'off') {
		$target = '';
	}
	switch($gallery->app->graphics)	{
		case "NetPBM":
			$err = exec_wrapper(toPnmCmd($src) .
				(($target > 0) ? (' | ' .NetPBM('pnmscale',
				" -xysize $target $target")) : '')
				. ' | ' . fromPnmCmd($out, $quality));
			/* copy over EXIF data if a JPEG if $keepProfiles is
			 * set. Unfortunately, we can't also keep comments. */ 
			if ($keepProfiles && eregi('\.jpe?g$', $src)) {
				if (isset($gallery->app->use_exif)) {
					exec_wrapper(fs_import_filename($gallery->app->use_exif, 1) . ' -te '
						. fs_import_filename($src, 1) . ' '
						. fs_import_filename($out, 1));
				} else {
					processingMsg(_('Unable to preserve EXIF data (jhead not installed)') . "\n");
				}
			}
			break;
		case "ImageMagick":
			$src = fs_import_filename($src);
			$out = fs_import_filename($out);
			/* Preserve comment, EXIF data if a JPEG if $keepProfiles is set. */
			$err = exec_wrapper(ImCmd('convert', "-quality $quality "
					. ($target ? "-size ${target}x${target} " : '')
					. ($keepProfiles ? ' ' : ' +profile \'*\' ')					
					. $src
/*
## start Image Magick fixed width size hack
*/
					. ($target ? " -geometry 150x800 " : '')// change width times height value here
					//. ($target ? " -geometry ${target}x${target} " : '')

/*
## end Image Magick fixed width size hack
*/

					. $out));
			break;
		default:
			if (isDebugging())
				echo "<br>" . _("You have no graphics package configured for use!")."<br>";
			return 0;
			break;
	}
}

uploaded a load of landscape and portrait photos and all thumbs are now processed using a fixed width.... yet they're aspect ratio remains the same..

result.

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Tue, 2004-03-09 00:47

just realised that the .sized image being generated by gallery shares the same dimensions as the .thumb image.... so clicking on a thumb gives you a resized image the same size as the thumb.

doh.

working on a fix

 
hdotnet
hdotnet's picture

Joined: 2003-01-29
Posts: 23
Posted: Mon, 2004-05-17 17:53

found a fix....
just have to fiddle with compress_image in Util.php a little:

function compress_image($src, $out, $target, $quality, $keepProfiles=false) {
	global $gallery;

	if ($target === 'off') {
		$target = '';
	}
	switch($gallery->app->graphics)	{
		case "NetPBM":
			$err = exec_wrapper(toPnmCmd($src) .
				(($target > 0) ? (' | ' .NetPBM('pnmscale',
				" -xysize $target $target")) : '')
				. ' | ' . fromPnmCmd($out, $quality));
			/* copy over EXIF data if a JPEG if $keepProfiles is
			 * set. Unfortunately, we can't also keep comments. */ 
			if ($keepProfiles && eregi('\.jpe?g$', $src)) {
				if (isset($gallery->app->use_exif)) {
					exec_wrapper(fs_import_filename($gallery->app->use_exif, 1) . ' -te '
						. fs_import_filename($src, 1) . ' '
						. fs_import_filename($out, 1));
				} else {
					processingMsg(_('Unable to preserve EXIF data (jhead not installed)') . "\n");
				}
			}
			break;
		case "ImageMagick":
			$src = fs_import_filename($src);
			$out = fs_import_filename($out);
/*
## start Image Magick fixed width size hack
*/
			list($width, $height, $type, $attr) = getimagesize($src);
			if($height > $width){
							$geometryString = " -geometry 150x800 ";
			}else{
							$geometryString = " -geometry ${target}x${target} ";
			}
			/* Preserve comment, EXIF data if a JPEG if $keepProfiles is set. */
			$err = exec_wrapper(ImCmd('convert', "-quality $quality "
					. ($target ? "-size ${target}x${target} " : '')
					. ($keepProfiles ? ' ' : ' +profile \'*\' ')					
					. $src
					. ($target ? $geometryString : '')// change width times height value here
/* 
## end Image Magick fixed width size hack 
*/ 
					//. ($target ? " -geometry ${target}x${target} " : '')
					. $out));
			break;
		default:
			if (isDebugging())
				echo "<br>" . _("You have no graphics package configured for use!")."<br>";
			return 0;
			break;
	}
}
 
eosguy

Joined: 2005-07-27
Posts: 38
Posted: Sat, 2007-06-02 14:45

Has anyone managed to set the thumbnail width for Gallery 2.2? Any help is greatly appreciated.
-----
Photography gallery at http://www.kennyyeoh.com