..oO(macca)
Some little hints:
>function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
What about image names containing a dot? Better use pathinfo():
$ext = pathinfo($name, PATHINFO_EXTENSION);
if (preg_match('/jpg|jpeg|JPG|JPEG/',$system[1])){
Make use of the power of regular expressions:
if (preg_match('/jpe?g/i', $ext)) {
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png|PNG/',$system[1])){
if (preg_match('/png/i', $ext)) {
$src_img=imagecreatefrompng($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
You can drop the last part. Just add the equalness to one of the
previous operations (<= or >=). Keeps the code a bit shorter.
>if (preg_match("/png/",$system[1]))
With your original code this part will fail if the extension is PNG. At
the beginning of the function you checked for both lower- and uppercase,
here you don't. Better:
if (preg_match('/png/i', $ext)) {
To avoid this preg_match() call, you could also set a variable at the
beginning, which file format to use. Then it would be as simple as
if ($mode == 'png') {
Micha