GIF89a;
Direktori : /home/serb/public_html/lib/ |
Current File : /home/serb/public_html/lib/ak_php_img.php |
<?php // -------------- RESIZE FUNCTION ------------- // Function for resizing any jpg, gif, or png image files function ak_img_resize($target, $newcopy, $w, $h = false, $ext) { list($w_orig, $h_orig) = getimagesize($target); $scale_ratio = $w_orig / $h_orig; if ($h === false) { $h = round(($h_orig * $w) / $w_orig); } if (($w / $h) > $scale_ratio) { $w = $h * $scale_ratio; } else { $h = $w / $scale_ratio; } $img = ""; $ext = strtolower($ext); if ($ext == "gif"){ $img = imagecreatefromgif($target); } else if($ext =="png"){ $img = imagecreatefrompng($target); } else { $img = imagecreatefromjpeg($target); } $tci = imagecreatetruecolor($w, $h); // imagecopyresampled(dst_img, src_img, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h) imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig); if ($ext == "gif"){ imagegif($tci, $newcopy); } else if($ext =="png"){ imagepng($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } } // $this->image_dst_x = $this->image_x; // $this->image_dst_y = round(($this->image_src_y * $this->image_x) / $this->image_src_x); // ------------- THUMBNAIL (CROP) FUNCTION ------------- // Function for creating a true thumbnail cropping from any jpg, gif, or png image files function ak_img_thumb($target, $newcopy, $w, $h = false, $ext) { list($w_orig, $h_orig) = getimagesize($target); if ($h === false) { $h = round(($h_orig * $w) / $w_orig); } $src_x = ($w_orig / 2) - ($w / 2); $src_y = ($h_orig / 2) - ($h / 2); $ext = strtolower($ext); $img = ""; if ($ext == "gif"){ $img = imagecreatefromgif($target); } else if($ext =="png"){ $img = imagecreatefrompng($target); } else { $img = imagecreatefromjpeg($target); } $tci = imagecreatetruecolor($w, $h); imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w, $h); if ($ext == "gif"){ imagegif($tci, $newcopy); } else if($ext =="png"){ imagepng($tci, $newcopy); } else { imagejpeg($tci, $newcopy, 84); } } function getRequestHeaders() { if (function_exists("apache_request_headers")) { if($headers = apache_request_headers()) { return $headers; } } $headers = array(); // Grab the IF_MODIFIED_SINCE header if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $headers['If-Modified-Since'] = $_SERVER['HTTP_IF_MODIFIED_SINCE']; } return $headers; }