thumbnail creation

zoozoozoo

New member
hello all,

im urgently looking for a solution to create
thumbnails (on the fly) when uploading image-files via dadabik 4.0. ive surfed the board and found a topic where this issue has been discussed, but this one doesn't seem to work for me...perhaps because i'm running v.4 and not 3.2... could someone help me please..?

here is my code:

// line 1065 business_logic.php

else { //go ahead and copy the file into the upload directory
if (!(move_uploaded_file($file_name_temp, $upload_directory.'dadabik_tmp_file_'.$file_name))) {
$check = 0;
$name == $upload_relative_url.$field_value;
$filename == $upload_relative_url.'thum_'.$field_value;
createthumb($name,$filename,100,100);

and the function:

// i inserted this after
// after // end function write_temp_uploaded_files in linie 1080

//create thumbnails
function createthumb($name,$filename,$new_w,$new_h)
{
$system=explode(".",$name);
if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);}
if (preg_match("/png/",$system[1])){$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;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
} else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
//

 
Top