function make_thumbs($img) { global $BASE_DIR, $BASE_URL; $path_info = pathinfo($img); $path = $path_info['dirname'] . "/"; $img_file = $path_info['basename']; $thumb = $path . '.' . $img_file; $img_info = getimagesize($BASE_DIR . $path . $img_file); $w = $img_info[0]; $h = $img_info[1]; $nw = 96; $nh = 96; if ($w <= $nw && $h <= $nh) { header('Location: ' . $BASE_URL . $path . $img_file); exit; } if (is_file($BASE_DIR . $thumb)) { $t_mtime = filemtime($BASE_DIR . $thumb); $o_mtime = filemtime($BASE_DIR . $img); if ($t_mtime > $o_mtime) { //echo $BASE_URL.$path.'.'.$img_file; header('Location: ' . $BASE_URL . $path . '.' . $img_file); exit; } } $img_thumbs = Image_Transform::factory(IMAGE_CLASS); $img_thumbs->load($BASE_DIR . $path . $img_file); if ($w > $h) { $nh = unpercent(percent($nw, $w), $h); } else { if ($h > $w) { $nw = unpercent(percent($nh, $h), $w); } } $img_thumbs->resize($nw, $nh); $img_thumbs->save($BASE_DIR . $thumb); $img_thumbs->free(); chmod($BASE_DIR . $thumb, 0666); if (is_file($BASE_DIR . $thumb)) { //echo "Made:".$BASE_URL.$path.'.'.$img_file; header('Location: ' . $BASE_URL . $path . '.' . $img_file); exit; } }
// Original image width $oh = $tmpgif[1]; // Original image height if ($mode) { // Just smash it up to fit the dimensions $nw = $w; $nh = $h; } else { // Make it proportional. if ($ow > $oh) { $nw = $w; $nh = unpercent(percent($nw, $ow), $oh); } else { if ($oh > $ow) { $nh = $h; $nw = unpercent(percent($nh, $oh), $ow); } else { $nh = $h; $nw = $w; } } } if ($which == "Image1") { $whichhid = "image_one"; } if ($which == "Image2") { $whichhid = "image_two"; } if ($which == "Image3") { $whichhid = "image_three"; }