[8195] | 1 | <?php |
---|
| 2 | /***************************************\ |
---|
| 3 | | PHP OPTIMISATEUR | |
---|
[8226] | 4 | | Plugin CreateCustomThumbs 1.0 | |
---|
[8195] | 5 | \***************************************/ |
---|
| 6 | |
---|
[8226] | 7 | ## Différents traitements sur les miniatures : taille fixe & cadre (2 couleurs) |
---|
[8195] | 8 | ## Dépend de la valeur de $DIMthumbnail |
---|
| 9 | |
---|
| 10 | // CreateCustomThumbs à la priorité sur ConvertPan |
---|
| 11 | if (isset($PluginsProcess['convert_pan']) OR !isset($BlockThumbnail)) { |
---|
[8226] | 12 | |
---|
| 13 | $FileSource = $FilesSource[$i]; // fichier de travail |
---|
[8195] | 14 | $DIMthumbnailV = $PluginsProcess['create_custom_thumbs']['DIMthumbnailV']; // Hauteur de l'image |
---|
[8226] | 15 | $FRAMEparams = $PluginsProcess['create_custom_thumbs']['FRAMEparams']; // Paramètres du cadre |
---|
| 16 | |
---|
| 17 | // Miniature de taille personnalisée |
---|
| 18 | if ($DIMthumbnailV != '0') { |
---|
| 19 | $max = max($DIMthumbnail, $DIMthumbnailV); |
---|
[8195] | 20 | |
---|
[8226] | 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 - $DIMthumbnail) / 2; |
---|
| 33 | $offset_y = ($tmp_y - $DIMthumbnailV) / 2; |
---|
| 34 | |
---|
| 35 | exec('files\nconvert.exe -overwrite -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$resize_param.' -crop '.$offset_x.' '.$offset_y.' '.$DIMthumbnail.' '.$DIMthumbnailV.' -rmeta -rexifthumb "'.$FileSource.'"'); |
---|
| 36 | |
---|
| 37 | $BlockThumbnail = true; |
---|
| 38 | $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName; |
---|
[8195] | 39 | } |
---|
[8226] | 40 | |
---|
| 41 | // Cadre autour de la miniature |
---|
| 42 | if ($FRAMEparams != '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('files\nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb "'.$FilesSource[$i].'"'); |
---|
| 46 | $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | $FRAMEparams = ExplodeString($FRAMEparams); |
---|
| 50 | $colors['name'] = array_keys($FRAMEparams); |
---|
| 51 | $colors['size'] = array_values($FRAMEparams); |
---|
| 52 | |
---|
| 53 | $img = imagecreatefromjpeg($FileSource); |
---|
| 54 | $x = imagesx($img)-1; |
---|
| 55 | $y = imagesy($img)-1; |
---|
| 56 | |
---|
| 57 | $colors[0] = hex2RGB(substr($colors['name'][0],1)); |
---|
| 58 | $colors[1] = hex2RGB(substr($colors['name'][1],1)); |
---|
| 59 | $colors[0] = imagecolorallocate($img, $colors[0]['r'], $colors[0]['g'], $colors[0]['b']); |
---|
| 60 | $colors[1] = imagecolorallocate($img, $colors[1]['r'], $colors[1]['g'], $colors[1]['b']); |
---|
| 61 | |
---|
| 62 | for ($m=0; $m<$colors['size'][0]; $m++) { |
---|
| 63 | imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[0]); |
---|
| 64 | } |
---|
| 65 | for ($m=$colors['size'][0]; $m<$colors['size'][0]+$colors['size'][1]; $m++) { |
---|
| 66 | imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[1]); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | imagejpeg($img, $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName, $Qthumbnail); |
---|
| 70 | imagedestroy($img); |
---|
| 71 | |
---|
| 72 | $BlockThumbnail = true; |
---|
| 73 | $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName; |
---|
| 74 | } |
---|
[8195] | 75 | } |
---|
[8226] | 76 | |
---|
[8195] | 77 | ?> |
---|