Page 1 of 1

imagejpeg() unable to write to file error

Posted: Tue Aug 05, 2003 11:03 am
by kendall
Hello,

i have the following code:

[syntax=php]$image = imagecreatefromjpeg($url.'/'.$file);
$filename = explode('.',$file);
$imagesx = imagesx($image)/2;
$imagesy = imagesy($image)/2;
$thumbnail = imagecreate(100,100);
imagecopyresized($thumbnail,$image,0,0,$imagesx/2,$imagesy/2,100,100,100,100);
imagejpeg($thumbnail,$filename[0].'_alt.'.$filename[1],50);
imagedestroy($thumbnail);[/syntax]

on script debuggin i get a [quote]imagejpeg: unable to open 'band_image0_alt.jpg' for writing[/quote]

im am unsure as to what are the paramters to be for the imagejpeg() the documentation isnt specific what should be the paramaters?

Kendall

Posted: Tue Aug 05, 2003 11:06 am
by AVATAr
do you have write permissions on that directory?

Posted: Tue Aug 05, 2003 11:48 am
by kendall
AVATAr,

Yeah man i guess as the directory was newly created...the process is as follows :-

user creates a folder
user uploads file to folder
thumbnail is suppose to be created from file

note: directories are created umask(0); then mask(0777);
note: files were successfully uploaded even though no thumbs were created
note: thumnails files are renamed with an '_alt'
is file directory permissions the only reason why? what other reasons can there be

Kendall

Posted: Tue Aug 05, 2003 1:11 pm
by pootergeist
if they create a directory, surely the save path of the thumbnail should include that directory name?

imagejpeg($thumbnail, $url. '/' .$filename[0]. '_alt.' .$filename[1], 80);

note: upped the 50 quality to 80 (at a compression setting of 50 you are going to get pretty nasty looking thumbs)
Also, if you are using GD2+ you should use imagecreatetruecolor and imagecopyresized to assure a palette greater than 256 indices.

Last note: If you are using GD2+ you could try the thumbnailing class from here - which would simplify the calls and assure proportional thumbnails within a bounding limit box. Can also add bevel, drop shadow, motion blur, greyscale etc etc

Posted: Tue Aug 05, 2003 2:17 pm
by kendall
pootergeist,

why yes of course as it is the same path used to save the file (for a moment i was trying it url based thinking that was the problem) but tell me does it need the absolute path?

i acknowlgede you advice concerning the GD2+ i will look into it and c didnt no dat existed

doubt i have it (backward hosting)

Kendall

Posted: Tue Aug 05, 2003 3:14 pm
by kendall
yo poo,

man that thing worked man....damn took what i was trying to do for weeks and summed it up in a one day script

thanks