QUOTE FROM: J_P ON JUNE 13, 2009, 09:40:34 PM
In case it helps anyone, I just thought I’d add in how I’ve managed to create square thumbs without using phpThumb.
1/ In assets/snippets/maxigallery/css/default.css add the following to "ul.thumbs li":
width:size-you-want px;
height:size-you-want px;
overflow:hidden;
2/ In assets/snippets/maxigallery/watermark/Thumbnail.class.php, swap x and y around in line 264
What this seems to do (I think I’m right - it works anyways) is make sure that that the shortest dimension is used when the image is resized - before the swapping the x and y around the largest was being used resulting in a rectangular thumb.
The other larger dimension will then be masked by the overflow:hidden.
So I initially tried to implement the above, and it didn’t work; I then spent some 15 or 20 hours trying to put together phpThumb(), but I kept running into different issues - compatibility with PHP 5.3, and then different aspects were still not working. I realized that phpThumb() is not very portable; I can configure it in one spot, but when I move it to another server or install on new, I may run into any number of issues.
I then tried to do square thumbnails using only CSS, but I was only getting the top left of the pic, which doesn’t look good at all.
I decided to re-look at the above code suggestion, and there is one additional line that needs to be edited for it to work. See below:
This (lines 262-269):
function size_auto($size=100) {
//size
if ($this->img["x"]>=$this->img["y"]) {
$this->size_width($size);
} else {
$this->size_height($size);
}
}
becomes this:
function size_auto($size=100) {
//size
if ($this->img["y"]>=$this->img["x"]) {
$this->size_width($size);
} else {
$this->size_height($size);
}
}
And here is what is missing from the above quoted post - this (lines 279-286)
function size($size_x,$size_y) {
//size
if ( (($this->img["x"])/$size_x) >= (($this->img["y"])/$size_y) ) {
$this->size_width($size_x);
} else {
$this->size_height($size_y);
}
}
becomes this:
function size($size_x,$size_y) {
//size
if ( (($this->img["y"])/$size_y) >= (($this->img["x"])/$size_x) ) {
$this->size_width($size_x);
} else {
$this->size_height($size_y);
}
}
I think it may have been caused by updates being applied, adding in the second part of code, but it works, it creates square thumbnails (portrait pics are cut off on the bottom a little, and landscapes are cut off a little on the side, but it is very acceptable chopping).
Don’t forget the CSS addition above!!! Enjoy.