PDA

View Full Version : thumbnail viewer II outputting images



neo8223
02-21-2010, 02:17 PM
1) Script Title: Image Thumbnail Viewer II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm

3) Describe problem: Outputting the images in the loadarea to be a maximum width.

Hi guys, I've been working on this for ages and just cant seem to get it right. I have made a site and my own gallery using the thumbnail viewer with a bunch of php and my client wanted the images to be better quality... so i just increased the size of the images (being a bit of a n00b at php... actually website design in general) Now i want to view these images at a smaller size (800px max) and i simply cant resize the images on output.

Ive tried modifying the stylesheet, and even inlined the code into the page itself. The site works fine with portrait images (having less width) but not work landscape, as you can see.

Any bright ideas?

http://www.kingslist.co.uk/gallery2.php?id=101&&start=0

stringcugu
02-22-2010, 12:49 AM
put width=500 in the image----

<div id='loadarea' style='max-width: 500px'><a href='http://www.kingslist.co.uk/gallery2.php?id=101&&start=1'><img src = 'http://www.kingslist.co.uk/Events/101-0.jpg' width=500></a></div>

neo8223
02-23-2010, 11:53 PM
Hey thanks for the speedy reply. Unfortunately that still only resizes the first image that loads... but its a step in the right direction.

Any other ideas?

bluewalrus
02-24-2010, 12:12 AM
http://pear.php.net/package/Image_Transform

Then resize them with something like



$file = $uploaddir . basename($_FILES['uploadfile']['name']);
require_once 'Image/Transform.php';
//
//create transform driver object
$it = Image_Transform::factory('GD');
if (PEAR::isError($it)) {
die($it->getMessage());
}
//load the original file
$ret = $it->load("$file");
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
//scale it to 100 pixels wide to make a thumb
$ret = $it->scaleByLength(100);
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
//save it into a different file
$ext = substr($file_name,strlen($file_name)-3,3);
$clear_ext = explode("." . $ext, $file_name);
$file_name = $clear_ext[0];
$ret = $it->save("$dir$custom$gallery$thumb$file_name" . "_file" . $file_num . $output_format);
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
//load the original file again
$ret = $it->load("$file");
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
//scale it to 500px wide, the main display
$ret = $it->scaleByLength(500);
if (PEAR::isError($ret)) {
die($ret->getMessage());
}
//save it into a different file
$ret = $it->save("$dir$custom$gallery$file_name" . "_file" . $file_num . $output_format);
if (PEAR::isError($ret)) {
die($ret->getMessage());
}