- valider l'envoi de l'image uploadée (jusqu'à l'enregistrement sur le serveur)
Mon script marche sa enregsitré bien mes images
- valider la nouvelle image constituant le texte (jusqu'à l'enregistrement sur le serveur)
- fusionner ces deux fonctions pour n'en faire qu'une seule.
Alors sa bloque on ma proposer un bout de code
//keep image type///////////////////////////////
if($file_size){
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img2 = imagecreatefromjpeg($file_tmp);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img2 = imagecreatefrompng($file_tmp);
}elseif($file_type == "image/gif"){
$new_img2 = imagecreatefromgif($file_tmp);
}
//list width and height and keep height ratio.//////////////////////
list($width, $height) = getimagesize($file_tmp);
$imgratio2=$width/$height;
if ($imgratio2>1){
$newwidth2 = $ThumbWidth2;
$newheight2 = $ThumbWidth2/$imgratio2;
}else{
$newheight2 = $ThumbWidth2;
$newwidth2 = $ThumbWidth2*$imgratio2;
}
$infos = GetImageSize ($file_tmp);
//On stock les infos
$width = $infos[0];
$high = $infos[1];
$type = $infos[2];
//On crée notre nouvelle image:
$im = ImageCreate ($width, $high + 10); //On ajoute 10 pixels en bas pour ajouter les commentaires
$couleur_fond = ImageColorAllocate ($im, 0, 0, 0); //On stock la couleur noire pour le fond
ImagePng ($im); //Faire un if en fonction du type réccupéré pour mettre les bonne fonctions. Pour l'exemple on prendra le png
//On copie l'image uploadé dans notre nouvelle
ImageCopy ($im, $file_tmp, 0, 0, 0, 0, $width, $high);
//On insert la phrase de l'user
$blanc = ImageColorAllocate ($im, 255, 255, 255);
$texte = "toto toto toto";
ImageString($im, 2, $high+4, $width-18, $texte, $blanc);
//Et on crée l'image
ImagePng ($im);
//Et on crée l'image
Imagejpeg ($im,"$path_big/$rand_name.$file_ext");
mais j'obtiens encore une image noir ....
Si qlq veut bien me donner un coup de main !!