Thank you for your hospitality, Andre...
Here is the code...
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
// create the image with desired width and height
$img = imagecreatetruecolor($w, $h);
// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($img, $cols, $rows, $test);
}
}
}
$path = 'albums/userpics/10001/';
$nama = md5($_SERVER['REMOTE_ADDR'].rand()).'.jpg';
// print out the correct header to the browser
header("Content-type:image/jpeg");
imagejpeg($img,$path.$nama, 90);
$namathumb = 'thumb_'.$nama;
$thumb = imagecreatetruecolor(128,96);
imagealphablending($thumb, false);
imagecopyresized($thumb, $img, 0, 0, 0, 0, 128, 96, $w, $h);
imagejpeg($thumb, $path.$namathumb,90);
$namanormal = 'normal_'.$nama;
$normal = imagecreatetruecolor(400,300);
imagealphablending($normal, false);
imagecopyresized($normal, $img, 0, 0, 0, 0, 400, 300, $w, $h);
imagejpeg($normal, $path.$namanormal,90);
Basically, this code will generate three files, which are placed in folder "userpics/10001/". The size of these files are met the requirement of coppermine. folder "10001" should be got from user category folder. The problems are:
1. I do not know how coppermine could recoqnize user without session? If i could know the user, i think i will try to connect to the database and retrive this user information and then customize the user category folder.
2. Actually, i am a newbie in web programming, but i am eager to learn and work hard... So, please be patient with me...
Thank you very much for your kindness, Andre...