Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
Vieux 24/04/2006, 10h57   #1
Membre régulier
 
Homme Matthieu
Consultant informatique
Inscription : janvier 2003
Messages : 134
Détails du profil
Informations personnelles :
Nom : Homme Matthieu
Localisation : France, Nord (Nord Pas de Calais)

Informations professionnelles :
Activité : Consultant informatique
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : janvier 2003
Messages : 134
Points : 79
Points : 79
Par défaut [Images] [php5] convertir un bmp en jpeg

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
ermelir est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/04/2006, 12h54   #2
Membre actif
 
Inscription : mai 2005
Messages : 147
Détails du profil
Informations personnelles :
Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : mai 2005
Messages : 147
Points : 164
Points : 164
Citation:
Envoyé par ermelir
j'aurai aimé savoir si l'un d'entre vous avait reussi a convertir un bmp en jpeg via php.
pas tout à fait, mais la plupart des serveur sous nux disposent de la commande convert qui permet de le faire.
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
tthierry est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/04/2006, 14h11   #3
Membre confirmé
 
Inscription : janvier 2004
Messages : 242
Détails du profil
Informations forums :
Inscription : janvier 2004
Messages : 242
Points : 245
Points : 245
Genre :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
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;
 }
chaced est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +1. Il est actuellement 04h02.


 
 
 
 
Partenaires

Hébergement Web