Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path) {
- $s_path = trim($s_path);
- $o_path = trim($o_path);
- $save = $s_path . $save;
- $file = $o_path . $file;
- $ext = strtolower(end(explode('.',$save)));
- list($width, $height) = getimagesize($file) ;
- if(($width>$t_w) OR ($height>$t_h)) {
- $r1 = $t_w/$width;
- $r2 = $t_h/$height;
- if($r1<$r2) {
- $size = $t_w/$width;
- }else{
- $size = $t_h/$height;
- }
- }else{
- $size=1;
- }
- $modwidth = $width * $size;
- $modheight = $height * $size;
- $tn = imagecreatetruecolor($modwidth, $modheight) ;
- switch ($ext) {
- case 'jpg':
- case 'jpeg':
- $image = imagecreatefromjpeg($file) ;
- break;
- case 'gif':
- $image = imagecreatefromgif($file) ;
- break;
- case 'png':
- $image = imagecreatefrompng($file) ;
- break;
- }
- imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
- imagejpeg($tn, $save, 100) ;
- return;
- }
- //just the resize; first one resizes properly, second one resizes sometimes, but dark images tend to turn fully black
- Resize_Image($fullname,$fullname,600,600,'fotos/'.$urlnaam.'/large/','fotos/'.$urlnaam.'/large/');
- Resize_Image($fullname,$fullname,120,120,'fotos/'.$urlnaam.'/thumbs/','fotos/'.$urlnaam.'/large/');
- ?>
Add Comment
Please, Sign In to add comment