1 | <?php |
---|
2 | /***************************************\ |
---|
3 | | PHP OPTIMISATEUR | |
---|
4 | | Plugin CreateCustomThumbs 1.0.a | |
---|
5 | \***************************************/ |
---|
6 | |
---|
7 | ## Différents traitements sur les miniatures : taille fixe & cadre (2 couleurs) |
---|
8 | ## Dépend de la valeur de $CONF['DIMthumbnail'] |
---|
9 | |
---|
10 | // CreateCustomThumbs à la priorité sur ConvertPan |
---|
11 | if (isset($BlockThumbnail['convert_pan']) OR !isset($BlockThumbnail)) { |
---|
12 | |
---|
13 | $FileSource = $FilesSource[$i]; // fichier de travail |
---|
14 | $CCT_dimthumbnail = $CONF['Plugins']['create_custom_thumbs']['DIMthumbnailV']; // Hauteur de l'image |
---|
15 | $CCT_frameparams = $CONF['Plugins']['create_custom_thumbs']['FRAMEparams']; // Paramètres du cadre |
---|
16 | |
---|
17 | // Miniature de taille personnalisée |
---|
18 | if ($CCT_dimthumbnail != 0) { |
---|
19 | $max = max($CONF['DIMthumbnail'], $CCT_dimthumbnail); |
---|
20 | |
---|
21 | // on prend la miniature au milieu de l'image |
---|
22 | if ($FileInfos['Height'] >= $FileInfos['Width']) { |
---|
23 | $resize_param = $max.' 0'; |
---|
24 | $tmp_x = $max; |
---|
25 | $tmp_y = $max * $FileInfos['Height'] / $FileInfos['Width']; |
---|
26 | } else { |
---|
27 | $resize_param = '0 '.$max; |
---|
28 | $tmp_x = $max * $FileInfos['Width'] / $FileInfos['Height']; |
---|
29 | $tmp_y = $max; |
---|
30 | } |
---|
31 | |
---|
32 | $offset_x = ($tmp_x - $CONF['DIMthumbnail']) / 2; |
---|
33 | $offset_y = ($tmp_y - $CCT_dimthumbnail) / 2; |
---|
34 | |
---|
35 | exec('include\nconvert.exe -overwrite -q '.$CONF['Qthumbnail'].' -out jpeg -o "'.$FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$resize_param.' -crop '.$offset_x.' '.$offset_y.' '.$CONF['DIMthumbnail'].' '.$CCT_dimthumbnail.' -rmeta -rexifthumb "'.$FileSource.'"'); |
---|
36 | |
---|
37 | $BlockThumbnail['create_custom_thumbs'] = true; |
---|
38 | $FileSource = $FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg'; |
---|
39 | } |
---|
40 | |
---|
41 | // Cadre autour de la miniature |
---|
42 | if ($CCT_frameparams['size1'] != 0 OR $CCT_frameparams['size2'] != 0) { |
---|
43 | // Si la miniature n'a pas encore été générée il faut le faire |
---|
44 | if ($FileSource == $FilesSource[$i]) { |
---|
45 | exec('include\nconvert.exe -q '.$CONF['Qthumbnail'].' -out jpeg -o "'.$FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMthumbnail'].' '.$CONF['DIMthumbnail'].' -rmeta -rexifthumb "'.$FilesSource[$i].'"'); |
---|
46 | $FileSource = $FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg'; |
---|
47 | } |
---|
48 | |
---|
49 | $img = imagecreatefromjpeg($FileSource); |
---|
50 | $x = imagesx($img)-1; |
---|
51 | $y = imagesy($img)-1; |
---|
52 | |
---|
53 | $colors[0] = hex2RGB($CCT_frameparams['color1']); |
---|
54 | $colors[1] = hex2RGB($CCT_frameparams['color2']); |
---|
55 | $colors[0] = imagecolorallocate($img, $colors[0]['r'], $colors[0]['g'], $colors[0]['b']); |
---|
56 | $colors[1] = imagecolorallocate($img, $colors[1]['r'], $colors[1]['g'], $colors[1]['b']); |
---|
57 | |
---|
58 | for ($m=0; $m<$CCT_frameparams['size1']; $m++) { |
---|
59 | imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[0]); |
---|
60 | } |
---|
61 | for ($m=$CCT_frameparams['size1']; $m<$CCT_frameparams['size1']+$CCT_frameparams['size2']; $m++) { |
---|
62 | imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[1]); |
---|
63 | } |
---|
64 | |
---|
65 | imagejpeg($img, $FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg', $CONF['Qthumbnail']); |
---|
66 | imagedestroy($img); |
---|
67 | |
---|
68 | $BlockThumbnail['create_custom_thumbs'] = true; |
---|
69 | $FileSource = $FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg'; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | ?> |
---|