//declare varibles ini_set("memory_limit","100M"); $base = '/home/bostonco/public_html/images/gallery/'; $ss = stripslashes($page); $page = $ss; If (empty($type)){ $type='ws'; $root=$base.$page.'/'; $size=200; } else{ $root= $base.$page.'/'; $size=700; } If (empty($page)){ exit(); } function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp,$im_width,$im_height) { $img_src = imagecreatefromjpeg($sourcefile); $img_dst = imagecreatetruecolor($forcedwidth,$forcedheight); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $forcedwidth,$forcedheight, $im_width,$im_height); imagejpeg($img_dst, $destfile, $imgcomp); imagedestroy($img_dst); @chmod($g_dstfile, 0777); return true; } function resizealpha($wm_new_width, $wm_new_height, $sourcefile, $destfile) { $im = imagecreatefrompng($sourcefile); $sourcefile_width = imagesx($im); $sourcefile_height = imagesy($im); $sourcefile_new_width = $wm_new_width ; $sourcefile_new_height = $wm_new_height ; $im_dest = imagecreatetruecolor ($sourcefile_new_width, $sourcefile_new_height); imagealphablending($im_dest, false); imagecopyresampled($im_dest, $im, 0, 0, 0, 0, $sourcefile_new_width, $sourcefile_new_height, $sourcefile_width, $sourcefile_height); imagesavealpha($im_dest, true); imagepng($im_dest, $destfile); imagedestroy($im_dest); } function strip_ext($name) { $ext = strrchr($name, '.'); if($ext !== false) { $name = substr($name, 0, -strlen($ext)); } $name2 = str_replace('_', ' ', $name); return $name2; } function watermark($sourcefile, $destfile, $watermark, $imgcomp, $dest_x, $dest_y) { // or place bottom left $photoImage = ImageCreateFromJPEG($sourcefile); ImageAlphaBlending($photoImage, true); $logoImage = ImageCreateFromPNG($watermark); $logoW = ImageSX($logoImage); $logoH = ImageSY($logoImage); ImageCopy($photoImage, $logoImage, $dest_x, $dest_y, 0, 0, $logoW, $logoH); ImageJPEG($photoImage, $destfile, $imgcomp); @chmod($destfile, 0777); ImageDestroy($photoImage); ImageDestroy($logoImage); } function makeimagefile($root,$image,$page,$size,$type,$base){ //load images $wm = imagecreatefrompng($base.'watermark.png'); $im = imagecreatefromjpeg($root.$image); //get sizes $sz=$size; $im_width=imageSX($im); $im_height=imageSY($im); $wm_width=imageSX($wm); $wm_height=imageSY($wm); // work out new sizes if($im_width >= $im_height) { $factor = $sz/$im_width; $im_new_width = $sz; $im_new_height = $im_height * $factor; } else { $factor = $sz/$im_height; $im_new_height = $sz; $im_new_width = $im_width * $factor; } $wm_new_width = $im_new_width; $wm_new_height = $wm_new_width * $wm_height/$wm_width; //find bottom middle placement for watermark $dest_x = ( ( $im_new_width - $wm_new_width ) / 2 ); $dest_y = $im_new_height- $wm_new_height ; $im_destfile = $root.$type.'/'.$type.'_'.$image; $wm_destfile = $base.$wm_new_width.'x'.$wm_new_height.'watermark.png'; ImageDestroy($im); ImageDestroy($wm); $wm = $base.'watermark.png'; $im = $root.$image; resampimagejpg($im_new_width, $im_new_height, $im, $im_destfile, 100, $im_width,$im_height); if(!is_file($wm_destfile)){resizealpha($wm_new_width, $wm_new_height, $wm, $wm_destfile);} watermark($im_destfile, $im_destfile, $wm_destfile, 75, $dest_x, $dest_y); } //no image check //make dir if cant find one but make sure real request if(is_file($root.'/'.$page.'.php')){ if(!is_dir($root.'/'.$type)){ @chmod($root, 0777); @chmod($base, 0777); @mkdir($root.'/'.$type,0777); @chmod($root.'/'.$type, 0777); } } //read directory if ($directory = @opendir($root)){ while($file = readdir($directory)){ if ($file != "." && $file != ".."){ if(is_file($root.$file)){ if($file != 'index.php'){@chmod($root.$file, 0777); //make image if no image if(!is_file($root.'/'.$type.'/'.$type.'_'.$file)){ makeimagefile($root,$file,$page,$size,$type,$base);} //output list of thumbs if type is thumbs If ($type == 'ws' ){ $file_name= strip_ext($file) ; $gis=getimagesize("/home/bostonco/public_html/images/gallery/$page/ws/ws_$file"); $str="