Bonjour,

j'aimerais faire un petit script qui génèrera 2 miniatures à partir d'une image principale déjà présente sur le serveur.

J'obtiens 2 miniatures noires.
Les images ont les bonnes proportions, le script n'est donc pas totalement à la rue

Voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
$id = $_GET['id'];
 
$img_src_chemin = '../images/catal/'.$id.'.jpg';
$img_dst_chemin = '../images/catal/'.$id.'_zoom.jpg';
$img_dst_chemin_2 = '../images/catal/'.$id.'_thumb.jpg';
 
$img_src_resource = imagecreatefromjpeg( $img_src_chemin );
$img_src_resource_2 = imagecreatefromjpeg( $img_src_chemin );
 
$img_src_width = imagesx( $img_src_resource );
$img_src_height = imagesy( $img_src_resource );
 
if ($img_src_width < $img_src_height) {
  $x = round((315*$img_src_width)/$img_src_height);
  $x_2 = round((75*$img_src_width)/$img_src_height);
  $img_dst_resource = imagecreatetruecolor( $x, 315 );
  $img_dst_resource_2 = imagecreatetruecolor( $x_2, 75 );
}
else {
  $y = round((315*$img_src_height)/$img_src_width);
  $y_2 = round((75*$img_src_height)/$img_src_width);
  $img_dst_resource = imagecreatetruecolor( 315, $y );
  $img_dst_resource_2 = imagecreatetruecolor( 75, $y_2 );
}
 
imagejpeg( $img_dst_resource, $img_dst_chemin );
imagejpeg( $img_dst_resource_2, $img_dst_chemin_2 );
Merci pour votre éventuelle contribution.