function CreateImageToCache($handle, $thumb_w, $thumb_h, $back, $opt, $src) { $remote_image = DetectImage($handle); $w = imagesx($remote_image); $h = imagesy($remote_image); if ($h != 0) { $q = $w / $h; } // Generate size of thumb if ($thumb_w == -1 or $thumb_h == -1) { if ($thumb_w == -1 and $thumb_h == -1) { $thumb_w = $_GET['img_w']; $thumb_h = $_GET['img_h']; } else { if ($thumb_h != -1 and $thumb_w == -1) { $thumb_w = (int) $thumb_h * $q; } if ($thumb_h == -1 and $thumb_w != -1) { $thumb_h = (int) $thumb_w / $q; } } } // Valid size of the thumb if ($thumb_w > 1000) { $thumb_w = 650; } if ($thumb_w < 10) { $thumb_w = 10; } if ($thumb_h > 1000) { $thumb_h = 650; } if ($thumb_h < 10) { $thumb_h = 10; } // create thumb $thumb = imagecreatetruecolor($thumb_w, $thumb_h); // fill color if (is_string($back) && stristr($back, 'transparent')) { imagealphablending($thumb, true); imagecolortransparent($thumb, imagecolorallocatealpha($thumb, 255, 255, 255, 127)); } else { imagefill($thumb, 0, 0, imagecolorallocate($thumb, $back[0], $back[1], $back[2])); } imagecopyresampled($thumb, $remote_image, 0, 0, 0, 0, $thumb_w, $thumb_h, $w, $h); // Case Corsia if ($opt == '_corsia_') { //imagefilter($thumb, IMG_FILTER_BRIGHTNESS, 80); $src_t = CACHE_DEFAULT . 'em-producao.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Case Reservado if ($opt == '_reservado_') { $src_t = CACHE_DEFAULT . 'reservado.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Case Vendido if ($opt == '_vendido_') { $src_t = CACHE_DEFAULT . 'vendido.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Armazena a imagem localmente imagejpeg($thumb, $src, 80); // Envia a imagem SendImageFromCache($src, 0); }
function CreateImageToCache($handle, $thumb_w, $thumb_h, $back, $opt, $src) { $remote_image = DetectImage($handle); list($w, $h) = getimagesize($handle); if ($h != 0) { $q = $w / $h; } // Check image size if (getimagesize($handle)) { list($w, $h) = getimagesize($handle); } if ($h != 0) { $q = $w / $h; } // Generate size of thumb if ($thumb_w == -1 or $thumb_h == -1) { if ($thumb_w == -1 and $thumb_h == -1) { $thumb_w = $_GET['img_w']; $thumb_h = $_GET['img_h']; } else { if ($thumb_h != -1 and $thumb_w == -1) { $thumb_w = (int) $thumb_h * $q; } if ($thumb_h == -1 and $thumb_w != -1) { $thumb_h = (int) $thumb_w / $q; } } } // Valid size of the thumb if ($thumb_w > 1000) { $thumb_w = 650; } if ($thumb_w < 10) { $thumb_w = 10; } if ($thumb_h > 1000) { $thumb_h = 650; } if ($thumb_h < 10) { $thumb_h = 10; } // Gera thumb $thumb = imagecreatetruecolor($thumb_w, $thumb_h); $f = imagecolorallocate($thumb, $back[0], $back[1], $back[2]); imagefill($thumb, 0, 0, $f); // Aplica Imagem sobre thumb imagecopyresampled($thumb, $remote_image, 0, 0, 0, 0, $thumb_w, $thumb_h, $w, $h); // Case Corsia if ($opt == '_corsia_') { //imagefilter($thumb, IMG_FILTER_BRIGHTNESS, 80); $src_t = CACHE_DEFAULT . 'em-producao.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Case Reservado if ($opt == '_reservado_') { $src_t = CACHE_DEFAULT . 'reservado.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Case Vendido if ($opt == '_vendido_') { $src_t = CACHE_DEFAULT . 'vendido.png'; list($src_w, $src_h) = getimagesize($src_t); $res = imagecreatefrompng($src_t); imagealphablending($res, true); imagecopymerge($thumb, $res, $thumb_w / 2 - $src_w / 2, $thumb_h - $src_h - 3, 0, 0, $src_w, $src_h, 100); imagedestroy($res); } // Armazena a imagem localmente imagejpeg($thumb, $src, 90); // Envia a imagem header('Content-type: image/jpeg'); imagejpeg($thumb, null, 90); imagedestroy($thumb); imagedestroy($remote_image); exit; }