File: WIAdmin/WIModule/modules/image_resize.php

Recommend this page to a friend!
  Classes of Jules Warner  >  WICMS  >  WIAdmin/WIModule/modules/image_resize.php  >  Download  
File: WIAdmin/WIModule/modules/image_resize.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: WICMS
Database driven content management system with PDO
Author: By
Last change:
Date: 3 years ago
Size: 825 bytes
 

Contents

Class file image Download


<!-- ******** image_resize.php ******** -->

<?php
function img_resize($target, $newcopy, $w, $h, $ext) {
    list(
$w_orig, $h_orig) = getimagesize($target);
   
$scale_ratio = $w_orig / $h_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);
   
imagejpeg($tci, $newcopy, 84);
}
?>



For more information send a message to info at phpclasses dot org.