coppermine-gallery.com/forum

Support => Français (French) => Language Specific Support => cpg1.4.x Français (French) => Topic started by: pixelmaniac on June 08, 2008, 07:39:17 PM

Title: Affichage d'un histogramme
Post by: pixelmaniac on June 08, 2008, 07:39:17 PM
Bonjour à tous.

J'aimerais afficher l'histogramme (ou graphique) de l'exposition ou de la balance des couleurs dans ma galerie dans la description des images (dans la partie exif plus précisément), j'avais fais une petite modification sur ma précédente galerie qui me générait un hist_nomdelaphoto.png qui marchait au poil mais depuis que j'ai tout effacé, impossible de remettre la main sur ce plugin ou un hack identique...

help me !
Title: Re: Affichage d'un hitogramme
Post by: François Keller on June 08, 2008, 08:11:24 PM
euh! jamais entendu parler de ce genre de plugin. C'était avec une galerie coppermine ?
Title: Re: Affichage d'un histogramme
Post by: Pascal YAP on June 09, 2008, 05:27:25 PM
Vous cherchez ceci ?  ;D
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fforum.coppermine-gallery.net%2Findex.php%3Faction%3Ddlattach%3Btopic%3D18759.0%3Battach%3D1430%3Bimage&hash=fe73097b2573c9a05fa9c01799711f44a8164c04)




1/ Ouvrez DISPLAYIMAGE.PHP et trouvez la fonction html_picinfo()

// WORK ONLY WITH GD 2.0, absolutly not with IMAGEMAGIK
// Update by PYAP 09 June 08 A.Sparrius
// Création Affichage Histogramme
    if (function_exists('ImageTypes')) {  // Only do if GD exists, not IMAGEMAGIC
      if($CONFIG['thumb_use']=='ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width'] ){
        $condition = true;
      }elseif($CONFIG['thumb_use']=='wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']){
        $condition = true;
      }elseif($CONFIG['thumb_use']=='any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']){
        $condition = true;
      }else{
       $condition = false;
      }
      if ($CONFIG['make_intermediate'] && $condition ) {
          $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
      } else {
          $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
      }
      if (strtoupper(substr($picture_url,strlen($picture_url)-3,3))=="JPG") {
        $info[$lang_picinfo['Histogram']]="<img src='histogramme.php?image=".$picture_url."'>";
      }
    }
// End Addition
    return theme_html_picinfo($info);
}



2/ Créez un nouveau fichier nommé histogramme.php et placez-le à la racine de votre Coppermine :

<?php
// Histogramme cr&#233;ation A.Sparrius 6/9/05 Updated by PYAP 09 June 08
// Free to use and change, provided you keep these lines :)
        
$tmp_image $_REQUEST['image'];
        
$image_array=split('[/\]',$tmp_image);
        
$image=$image_array[count($image_array)-1];
        
$path=rtrim($tmp_image,$image);
        
$hist_file="hist_".substr($image,0,strlen($image)-4).".png";
    if (
file_exists($path.$hist_file)) {
        
$im=imagecreatefromPNG($path $hist_file);
        
imagePNG($im);
        
imagedestroy($im);
        } else {
               
$im=imagecreatefromjpeg($path.$image);
               for(
$i=0;$i<imagesx($im);$i+=2)
       {
               for(
$j=0;$j<imagesy($im);$j++)
       {
       
$rrggbb=imagecolorsforindex ($imimagecolorat($im,$i,$j));
       
$r[$rrggbb['red']]+=1;
       
$g[$rrggbb['green']]+=1;
       
$b[$rrggbb['blue']]+=1;
        }
         }
               for (
$i=0;$i<256;$i++)
       {
       
$max[$i]=($r[$i]+$g[$i]+$b[$i])/3;
         }
       
$max_value=max($max)/150;
       
$m[0]=max($r);
       
$m[1]=max($b);
       
$m[2]=max($g);
       
$max_rgb=max($m)/150;
       
$im_out imageCreate (284164);
       
$background imageColorAllocate($im_out,100,100,100);
       
$box_fill   imageColorAllocate($im_out,70,70,70);
       
$white=ImageColorAllocate($im_out,200,200,200);
       
$black=ImageColorAllocate($im_out,20,20,20);
       
$grey=ImageColorAllocate($im_out,160,160,160);
       
$red=ImageColorAllocate($im_out,255,0,0);
       
$green=ImageColorAllocate($im_out,0,200,0);
       
$blue=ImageColorAllocate($im_out,0,0,255);
       
$ry=107;
       
$gy=107;
       
$by=107;

       
imageFilledRectangle($im_out,13,6,270,158,$box_fill);
       for(
$i=0;$i<256;$i++)
       {
        
imageLine($im_out$i+14157$i+14157-($max[$i]/$max_value),$white);
        
imageLine($im_out$i+13$ry$i+14157-($r[$i]/$max_rgb), $red);
        
imageLine($im_out$i+13$gy$i+14157-($g[$i]/$max_rgb), $green);
        
imageLine($im_out$i+13$by$i+14157-($b[$i]/$max_rgb), $blue);
       
$ry=157-($r[$i]/$max_rgb);
       
$gy=157-($g[$i]/$max_rgb);
       
$by=157-($b[$i]/$max_rgb);
       }
        
imageSetThickness($im_out,3);
        
imageLine($im_out,13,158,272,158,$grey);
        
imageLine($im_out,13,6,272,6,$black);
        
imageLine($im_out,13,6,13,158,$black);
        
imageLine($im_out,272,6,272,158,$grey);
        
imagePNG($im_out,$path $hist_file);
        
imageDestroy($im);
        
imagedestroy($im_out);
       
$im=imagecreatefromPNG($path $hist_file);
        
imagePNG($im);
        
imagedestroy($im);
       }
?>


3/ Ouvrez votre (ou vos) fichier de Langue, french.php en l'occurence,
    Cherchez  "$lang_picinfo = array("
et ajoutez la ligne suivante :
        'Histogram'=>'Histogramme',
Title: Re: Affichage d'un histogramme
Post by: pixelmaniac on June 09, 2008, 09:58:47 PM
Pascal YAP... je vous aime :)
Title: Re: Affichage d'un histogramme
Post by: Pascal YAP on June 10, 2008, 12:42:20 AM
QuotePascal YAP... je vous aime
Faut pas !!!!!! ça me gène !  ;D