Click to See Complete Forum and Search --> : image open, image edit, then image save.


Kyleva2204
07-15-2005, 09:55 PM
HOW!? I have done a few expirments, but Imageing is now my strong point.. this is what I have:
$image = imagecreatefromjpeg($_GET['file']);
//Grab new image
for( $i=0; $i<imagecolorstotal( $image ); $i++ ) {
$c = ImageColorsForIndex( $image, $i );
$t = ($c["red"]+$c["green"]+$c["blue"])/3;
imagecolorset( $image, $i, $t, $t, $t );
}
ImageJPEG($image, $_GET['file'], '100');
//Create temporary file and write to it
if (is_writable($_GET[file])){
echo $_GET[file];
$fp = $_GET[file];
$fp2 = fopen($fp, 'w') or die ("fudge!");
fwrite($fp2, $image) or die("fudge2!");
fclose($fp2);
echo "done?";
ImageDestroy($image);
}
else echo "dude.. this sucks";
feel free to just forget about what ive done and show me exactly how to do it.. :-D please! hahah

oh and it MIGHt help if i declared what is wrong.. well it practally erases the contents and places "Resource ID #2" as the text in the image file.. and sometiems it says "Fudge2!"... fwrite($fp2, $image) or die("fudge2!");
^_^

Kyleva2204
07-15-2005, 10:31 PM
Man why do i bother making a post anymore? If u look back on mosyt of my posts, I post sumtn.. then minuites later, i solve the problem.. Just to shorten this, yeah I figured it out :) but thanks for anyone that was willing to help.

BeachSide
07-15-2005, 11:34 PM
I wish it worked for me like that... then again maybe not. I'd probably wind up posting my life problems hoping they would solve themselves like that :p

SpectreReturns
07-16-2005, 01:08 AM
ImageCreateJPEG before you write it ot the file.

Kyleva2204
07-16-2005, 09:01 PM
ImageCreateJPEG before you write it ot the file.

huh? all i did was this:
$image = imagecreatefromjpeg($_GET[file]);
//Grab new image
imagetruecolortopalette($image, TRUE, 1000000);
for( $i=0; $i<imagecolorstotal( $image ); $i++ ) {
$c = ImageColorsForIndex( $image, $i );
$t = ($c["red"]+$c["green"]+$c["blue"])/3;
imagecolorset( $image, $i, $t, $t, $t );
}
ob_start();
ImageJPEG($image);
$image_buffer = ob_get_contents();
ob_end_clean();
//Create temporary file and write to it
save_file($image_buffer, "Made image black and white.");