|
Publicité | ||||||||||||||||||||||
|
|
#1 (permalink) |
|
Membre régulier
![]() Date d'inscription: janvier 2003
Messages: 132
|
bonjour a tous,
j'aurai aimé savoir si l'un d'entre vous avait reussi a convertir un bmp en jpeg via php. ceci dans le but de pouvoir integrer ces images dans un flash 8 qui ne supporte pas l'integration des images bmp a la volée. J'ai regardé du coté des fonctions gd, je n'ai rien trouvé qui me permettrait de faire cela... merci d'avance pour votre aide Bien cordialement |
|
|
|
|
|
#2 (permalink) | |
|
Membre habitué
![]() Date d'inscription: mai 2005
Localisation: Nice
Messages: 148
|
Citation:
sinon le programme est porté sous windows (il existe même une extension pour php sur cette plateforme). maintenant je ne sais pas si ça pourra te servir étant donné que je ne connais pas ton environnement. http://www.imagemagick.org/script/index.php |
|
|
|
|
|
|
#3 (permalink) |
|
Membre Confirmé
![]() Date d'inscription: janvier 2004
Messages: 246
|
Genre :
Code :
function bmp2jpg($nombmp,$nomjpg) { $p=imagecreatefrombmp($nombmp); if ($p) { imagejpeg($p, $nomjpg, 75); imagedestroy($p); return 1; } else return 0; } function imagecreatefrombmp($dir) { $bmp = ""; if (file_exists($dir)) { $file = fopen($dir,"r"); while(!feof($file)) $bmp .= fgets($file,filesize($dir)); if (substr($bmp,0,2) == "BM") { // Lecture du header $header = unpack("vtype/Vlength/v2reserved/Vbegin/Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vimportant", $bmp); extract($header); // Lecture de l'image $im = imagecreatetruecolor($width,$height); $i = 0; $diff = floor(($imagesize - ($width*$height*($bits/8)))/$height); for($y=$height-1;$y>=0;$y--) { for($x=0;$x<$width;$x++) { if ($bits == 32) { $b = ord(substr($bmp,$begin+$i,1)); $v = ord(substr($bmp,$begin+$i+1,1)); $r = ord(substr($bmp,$begin+$i+2,1)); $i += 4; } else if ($bits == 24) { $b = ord(substr($bmp,$begin+$i,1)); $v = ord(substr($bmp,$begin+$i+1,1)); $r = ord(substr($bmp,$begin+$i+2,1)); $i += 3; } else if ($bits == 16) { $tot1 = decbin(ord(substr($bmp,$begin+$i,1))); while(strlen($tot1)<8) $tot1 = "0".$tot1; $tot2 = decbin(ord(substr($bmp,$begin+$i+1,1))); while(strlen($tot2)<8) $tot2 = "0".$tot2; $tot = $tot2.$tot1; $r = bindec(substr($tot,1,5))*8; $v = bindec(substr($tot,6,5))*8; $b = bindec(substr($tot,11,5))*8; $i += 2; } $col = imagecolorexact($im,$r,$v,$b); if ($col == -1) $col = imagecolorallocate($im,$r,$v,$b); imagesetpixel($im,$x,$y,$col); } $i += $diff; } // retourne l'image return $im; imagedestroy($im); } else return false; } else return false; } |
|
|
|
|
|
![]() |
||
[Images] [php5] convertir un bmp en jpeg
|
||
| Outils de la discussion | |
|
|