View Full Version : Creating thumbnails with GD-libs

03-26-2004, 11:33 PM
I really would need some help to get some new ideas to solve my problem. Any help would be highly appriciated, cause I have very little hair left after all messing around... :)

I had a script that created thumbs out of imagefiles, and saved the thumb in the same directory as the image.
It worked well, but the disadvantage was that I had to upload the images with ftp, and then run the script.

I wanted to get som more functionality into it, to be able to upload the images with the browser.
So I upload an image to a temporary directory, creates the thumb and a new image, with the maximum size I decides in the script, stores the thumbs in one directory and the images in another and finally erases the uploaded file.

All works fine on my own server. On the hotell I get the new files created but they are empty (0 Byte).
I have tried to add some error checking, but I have no errors at all. The script are saying that everything went fine.
Since it works at home I don't think I have misspelled any comands or so, and since my first script worked I guess the hotells gd-version is able to do the job.
If I only copy the tempfile from the temp-dir to the image-dir that works, so I guess the permissions on the directorys are OK.

I have searched the web for ideas and found that some people had similar problems when the servers were running in safe mode, but I have still not found a solution for it.
The hotells server are running in safe mode, but my own are not. Could this be a problem for me? After all, the first script worked.
Will there be a difference with the owner and group depending on if I upload the file via ftp or http?

I submit the part of my code that are doing the rezising. Are there any errors? Can I add some better error-checking to get an idea of what is going wrong?

function resizeImage($sSourcefile, $dest_x, $dest_y, $sTargetfile, $jpegqual, $gd) {

if(!(is_readable($sSourcefile))) {
printf("<br /><script language=javascript>alert('Temporary file doesn't exist.');</script><br />");}
else {

chmod ($sTargetfile, 0755);

if(!(is_writable($sTargetfile))) {
printf("<br /><script language=javascript>alert('No write-permission to new file.');</script><br />");}

else {



$img_dst=($gd < 2 ? imagecreate($dest_x,$dest_y) : imagecreatetruecolor($dest_x,$dest_y));// Choose the proper command depending on the gd-lib version
$gd < 2 ? imagecopyresized($img_dst, $img_src, 0, 0, 0, 0, $dest_x, $dest_y, $img_src_size[0], $img_src_size[1]) : imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $dest_x, $dest_y, $img_src_size[0], $img_src_size[1]);
imagejpeg($img_dst, $sTargetfile, $jpegqual);

if(!(file_exists($sTargetfile))) {
return false; }
else {
return true; }

Please give me something to work with, while I still have some hair left.. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum