| Line 342... |
Line 342... |
| 342 |
$message = "Impossible de générer l'image sur le serveur. Extension ImageMagick absente.";
|
342 |
$message = "Impossible de générer l'image sur le serveur. Extension ImageMagick absente.";
|
| 343 |
$code = RestServeur::HTTP_CODE_ERREUR;
|
343 |
$code = RestServeur::HTTP_CODE_ERREUR;
|
| 344 |
throw new Exception($message, $code);
|
344 |
throw new Exception($message, $code);
|
| 345 |
}
|
345 |
}
|
| 346 |
} else if ($this->convertisseur == 'rsvg') {
|
346 |
} else if ($this->convertisseur == 'rsvg') {
|
| 347 |
$png = $this->convertirEnPNGAvecRsvg($svg);
|
347 |
$png = $this->convertirGraphiqueEnPNGAvecRsvg($svg);
|
| 348 |
} else {
|
348 |
} else {
|
| 349 |
$message = "Le convertisseur indiqué '{$this->convertisseur}' ne fait pas partie de la liste ".
|
349 |
$message = "Le convertisseur indiqué '{$this->convertisseur}' ne fait pas partie de la liste ".
|
| 350 |
"des convertisseurs disponibles : imagick, rsvg.";
|
350 |
"des convertisseurs disponibles : imagick, rsvg.";
|
| 351 |
$code = RestServeur::HTTP_CODE_ERREUR;
|
351 |
$code = RestServeur::HTTP_CODE_ERREUR;
|
| 352 |
throw new Exception($message, $code);
|
352 |
throw new Exception($message, $code);
|
| Line 369... |
Line 369... |
| 369 |
$convertisseur->clear();
|
369 |
$convertisseur->clear();
|
| 370 |
$convertisseur->destroy();
|
370 |
$convertisseur->destroy();
|
| 371 |
return $png;
|
371 |
return $png;
|
| 372 |
}
|
372 |
}
|
| Line 373... |
Line 373... |
| 373 |
|
373 |
|
| 374 |
public function convertirEnPNGAvecRsvg($svg) {
|
374 |
public function convertirGraphiqueEnPNGAvecRsvg($svg) {
|
| 375 |
$idFichier = $this->getIdFichier();
|
375 |
$idFichier = $this->getIdFichier();
|
| 376 |
$fichierPng = $this->config['cache_stockageChemin']."".$idFichier.'.png';
|
376 |
$fichierPng = $this->config['cache_stockageChemin'].$idFichier.'.png';
|
| 377 |
$fichierSvg = $this->config['cache_stockageChemin']."".$idFichier.'.svg';
|
377 |
$fichierSvg = $this->config['cache_stockageChemin'].$idFichier.'.svg';
|
| 378 |
file_put_contents($fichierSvg, $svg);
|
378 |
file_put_contents($fichierSvg, $svg);
|
| 379 |
$commande = "rsvg-convert $fichierSvg -w ".$this->largeurSVG ." -h ".$this->hauteurSVG ." -o $fichierPng";
|
379 |
$commande = "rsvg-convert $fichierSvg -w ".$this->largeurSVG ." -h ".$this->hauteurSVG ." -o $fichierPng";
|
| 380 |
//echo $commande; exit;
|
380 |
//echo $commande; exit;
|
| 381 |
$rsvg = exec($commande);
|
381 |
$rsvg = exec($commande);
|
| 382 |
$this->indexerFichierPng($fichierPng);
|
382 |
$this->indexerGraphiqueFichierPng($fichierPng);
|
| 383 |
$png = file_get_contents($fichierPng);
|
383 |
$png = file_get_contents($fichierPng);
|
| 384 |
return $png;
|
384 |
return $png;
|
| Line 385... |
Line 385... |
| 385 |
}
|
385 |
}
|
| 386 |
|
386 |
|
| 387 |
public function indexerFichierPng($fichierPng) {
|
387 |
public function indexerGraphiqueFichierPng($fichierPng) {
|
| 388 |
$img = imagecreatefrompng($fichierPng);
|
388 |
$img = imagecreatefrompng($fichierPng);
|
| 389 |
imagetruecolortopalette($img, false, 32);
|
389 |
imagetruecolortopalette($img, false, 32);
|