/ Published in: PHP
                    
                                        
Tweaked from the icant.co.uk thumbnail generator
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
##
#
# $name = full path to original source
# $filename = full path to thumbnail
# $new_w thumbnail width
# $new_h thumbnail height
# $debug echo a few diagnostics
#
##
function createthumb($name,$filename,$new_w=500,$new_h=373,$debug=false) {
$results = "";
$results = "file extension = $system <br>";
$results .= "image size = $old_x x $old_y <br>";
if($old_x > $old_y) {
$thumb_h = $new_h;
$ratio = $new_h / $old_y;
$thumb_w = ($old_x * $ratio);
}
if($old_x < $old_y) {
$thumb_w = $new_w;
$ratio = $new_w / $old_x;
$thumb_h = ($old_y * $ratio);
}
if($old_x == $old_y) {
$thumb_w = $new_w;
$thumb_h = $new_h;
}
if($new_h < $thumb_h) {
} else {
$yloc = 0;
}
$results .= "output size = $thumb_w x $thumb_h <br>
y offset = $yloc <br>";
} else {
}
if($debug) echo $results;
return "Resized the image successfully!";
}
?>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                