cs_Dfx4
Messages postés
31
Date d'inscription
dimanche 17 avril 2005
Statut
Membre
Dernière intervention
27 février 2006
-
30 sept. 2005 à 13:23
cs_Anthomicro
Messages postés
9433
Date d'inscription
mardi 9 octobre 2001
Statut
Membre
Dernière intervention
13 avril 2007
-
30 sept. 2005 à 17:55
Bonjour,
j'ai petit problème avec les images, certain images qui viennent de MMS
ne fonctionnne pas, cela me rend un carré noir !! Il copie pas l'image
de quoi cela peut-il venir ??
Aidez-moi SVP !!!!
function move_pict($src, $name) {
global $MM, $INFO, $DB, $SESS;
// Recherche du type de l'image et de l'extension
$ext = strtolower(strrchr($name, '.'));
if( !file_exists($src) ) return 'not found file';
if( !in_array($ext, explode('!', $INFO['accept_ext'])) ) return 'bad extension';
else {
// Type de fichier reconnu || 1 GIF, 2 JPG,
JPEG, 3 = PNG
if( list( $width, $height, $type, $opt ) =
getimagesize($src) ) {
// Si le type n'est pas GIF, JPG,
PNG
if( $type > 3 ) return 'bad
format';
else {
// Création du dossier
if( !$dh =
@opendir(RACINE."missmobiles/photos/".$SESS->user_id) ) {
if(
!mkdir(RACINE."missmobiles/photos/".$SESS->user_id) ) return 'not
dir';
}
// Taille maximum
list( $max_width,
$max_height )
= explode('x', $INFO['pict_size_b']);
list( $max_width_small, $max_height_small )
= explode('x', $INFO['pict_size_s']);
// Calcul des tailes
if( $width >= $height ) {
if( $width > $max_width ) {
$big_width = $max_width;
$propB
= $width/$max_width;
$big_height =
ceil($height/$propB)-1;
}
if( $width > $max_width_small
) {
$small_width = $max_width_small;
$propS
=
$width/$max_width_small;
$small_height
= ceil($height/$propS)-1;
}
}
else {
if( $height > $max_height ) {
$big_height = $max_height;
$propB
= $height/$max_height;
$big_width
= ceil($width/$propB)-1;
}
if( $height >
$max_height_small ) {
$small_height
= $max_height_small;
$propS
=
$height/$max_height_small;
$small_width
= ceil($width/$propS)-1;
}
}
// Si plus petit que les tailles enregsitrée
if( $width < $max_width && $height <
$max_height ) {
$big_width =
$width;
$big_height = $height;
}
if( $width < $max_width_small && $height
< $max_height_small ) {
$small_width = $width;
$small_height = $height;
}
// Création de l'image
$big_pict = imagecreatetruecolor(
$big_width, $big_height );
$small_pict = imagecreatetruecolor( $small_width,
$small_height );
// Création d'une image avec l'ancien contenue par
rapport au type
switch( $type ) {
case 1 : $pict =
@imagecreatefromgif($src); break;
case 2 : $pict =
@imagecreatefromjpeg($src); break;
case 3 : $pict =
@imagecreatefrompng($src); break;
default : return 'bad format';
}
// Copie du contenue
@imagecopyresized($big_pict, $pict, 0,0,0,0,
$big_width, $big_height, $width, $height);
@imagecopyresized($small_pict, $pict, 0,0,0,0,
$small_width, $small_height, $width, $height);
// Création des images
@imagejpeg($big_pict, RACINE."missmobiles/photos/".
$SESS->user_id ."/big.jpg", 100);
@imagejpeg($small_pict,
RACINE."missmobiles/photos/". $SESS->user_id ."/small.jpg", 100);
// Suppresion du file temporaire
// unlink($src);
return false;
}
}
else return 'bad format';
}
return 'error';
}