Index: /extensions/Histogram/admin/hgram_admin.tpl
===================================================================
--- /extensions/Histogram/admin/hgram_admin.tpl	(revision 8509)
+++ /extensions/Histogram/admin/hgram_admin.tpl	(revision 8509)
@@ -0,0 +1,3 @@
+<h2 style="float:right;top:-24px;position:relative;height:auto;font-size:12px;font-weight:normal;">{$plugin.HGRAM_VERSION}</h2>
+
+{$HGRAM_BODY_PAGE}
Index: /extensions/Histogram/admin/hgram_config.tpl
===================================================================
--- /extensions/Histogram/admin/hgram_config.tpl	(revision 8509)
+++ /extensions/Histogram/admin/hgram_config.tpl	(revision 8509)
@@ -0,0 +1,38 @@
+
+<h2>{'hgram_config'|@translate}</h2>
+
+<form method="POST" action="" id='iForm'>
+
+
+  <fieldset>
+    <legend>{'hgram_histosize'|@translate}</legend>
+    <label>{'hgram_width'|@translate}&nbsp;<input type="text" id='iHistoWidth' name='f_histo_width' value="{$hgramConfig.histo_width}"></label><br>
+    <label>{'hgram_height'|@translate}&nbsp;<input type="text" id='iHistoHeight' name='f_histo_height' value="{$hgramConfig.histo_height}"></label>
+  </fieldset>
+
+  <fieldset>
+    <legend>{'hgram_histo_rendering'|@translate}</legend>
+
+    <label>{'hgram_method'|@translate}&nbsp;
+      <select id='iHistoMethod' name='f_histo_method'>
+        <option value='L' {if $hgramConfig.histo_method=='L'}selected{/if}>{'hgram_luminance'|@translate} ({'hgram_like_photoshop'|@translate})</option>
+        <option value='A' {if $hgramConfig.histo_method=='A'}selected{/if}>{'hgram_average'|@translate}</option>
+        <option value='M' {if $hgramConfig.histo_method=='M'}selected{/if}>{'hgram_max'|@translate} ({'hgram_like_gimp'|@translate})</option>
+      </select>
+    </label><br>
+
+    <label>{'hgram_bg_color'|@translate}&nbsp;<input type="text" id='iColorBG' name='f_color_bg' value="{$hgramConfig.color_bg}"></label><br>
+    <label>{'hgram_global_color'|@translate}&nbsp;<input type="text" id='iColorV' name='f_color_v' value="{$hgramConfig.color_v}"></label><br>
+    <label>{'hgram_red_color'|@translate}&nbsp;<input type="text" id='iColorR' name='f_color_r' value="{$hgramConfig.color_r}"></label><br>
+    <label>{'hgram_green_color'|@translate}&nbsp;<input type="text" id='iColorG' name='f_color_g' value="{$hgramConfig.color_g}"></label><br>
+    <label>{'hgram_blue_color'|@translate}&nbsp;<input type="text" id='iColorB' name='f_color_b' value="{$hgramConfig.color_b}"></label><br>
+
+  </fieldset>
+
+
+  <div class='cfgBloc'>
+    <input type="submit" value="{'hgram_apply'|@translate}" name='submit_save_config'>
+  </div>
+
+</form>
+
Index: /extensions/Histogram/admin/index.php
===================================================================
--- /extensions/Histogram/admin/index.php	(revision 8509)
+++ /extensions/Histogram/admin/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Histogram/admin/plugin_admin.php
===================================================================
--- /extensions/Histogram/admin/plugin_admin.php	(revision 8509)
+++ /extensions/Histogram/admin/plugin_admin.php	(revision 8509)
@@ -0,0 +1,35 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+global $prefixeTable, $template;
+load_language('plugin.lang', HGRAM_PATH);
+
+$main_plugin_object = get_plugin_data($plugin_id);
+
+
+if(CommonPlugin::checkGPCRelease(3,2,0))
+{
+  $config=Array();
+  GPCCore::loadConfig('hgram', $config);
+
+  include(HGRAM_PATH."hgram_aip.class.inc.php");
+  $plugin_ai = new HGram_AIP($prefixeTable, $main_plugin_object->getFileLocation());
+}
+
+$plugin_ai->manage();
+
+
+
+?>
Index: /extensions/Histogram/hgram_aim.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_aim.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_aim.class.inc.php	(revision 8509)
@@ -0,0 +1,43 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.dnsalias.com
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  HGRAM_AIM : classe to manage plugin integration into plugin menu
+
+  --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+include_once('hgram_root.class.inc.php');
+
+class HGram_AIM extends HGram_root
+{
+  public function __construct($prefixeTable, $filelocation)
+  {
+    parent::__construct($prefixeTable, $filelocation);
+  }
+
+  /*
+    initialize events call for the plugin
+  */
+  public function initEvents()
+  {
+    parent::initEvents();
+    add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') );
+  }
+
+  /* ---------------------------------------------------------------------------
+  Function needed for plugin activation
+  --------------------------------------------------------------------------- */
+
+} // HGram_AIM class
+
+
+?>
Index: /extensions/Histogram/hgram_aip.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_aip.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_aip.class.inc.php	(revision 8509)
@@ -0,0 +1,198 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  HGram_AIP : classe to manage plugin admin pages
+
+  --------------------------------------------------------------------------- */
+
+if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+include_once('hgram_root.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTabSheet.class.inc.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+
+class HGram_AIP extends HGram_root
+{
+  protected $tabsheet;
+
+  public function __construct($prefixeTable, $filelocation)
+  {
+    parent::__construct($prefixeTable, $filelocation);
+    $this->checkRequest();
+
+    $this->loadConfig();
+    $this->initEvents();
+
+    $this->tabsheet = new tabsheet();
+/*    $this->tabsheet->add('database',
+                          l10n('hgram_database'),
+                          $this->getAdminLink()."&amp;f_tabsheet=database");*/
+    $this->tabsheet->add('config',
+                          l10n('hgram_config'),
+                          $this->getAdminLink()."&amp;f_tabsheet=config");
+  }
+
+  public function __destruct()
+  {
+    unset($this->tabsheet);
+    parent::__destruct();
+  }
+
+  /*
+    initialize events call for the plugin
+  */
+  public function initEvents()
+  {
+    parent::initEvents();
+    if($_REQUEST['f_tabsheet']=='search')
+    {
+      // load request builder JS only on the search page
+      GPCRequestBuilder::loadJSandCSS();
+    }
+    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
+    GPCCss::applyGpcCss();
+  }
+
+  /*
+    display administration page
+  */
+  public function manage()
+  {
+    global $template;
+
+    $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/hgram_admin.tpl");
+
+    switch($_REQUEST['f_tabsheet'])
+    {
+      case 'config':
+        $this->displayConfigPage();
+        break;
+    }
+
+    $this->tabsheet->select($_REQUEST['f_tabsheet']);
+    $this->tabsheet->assign();
+    $selected_tab=$this->tabsheet->get_selected();
+    $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
+
+    $template_plugin["HGRAM_VERSION"] = "<i>".$this->getPluginName()."</i> ".l10n('hgram_release').HGRAM_VERSION;
+
+    $template->assign('plugin', $template_plugin);
+    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+  }
+
+
+  /**
+   * check the $_REQUEST values and set default values
+   *
+   */
+  protected function checkRequest()
+  {
+    if(!isset($_REQUEST['f_tabsheet'])) $_REQUEST['f_tabsheet']='config';
+
+    if(!($_REQUEST['f_tabsheet']=='config')) $_REQUEST['f_tabsheet']='config';
+  }
+
+  /**
+   * manage display of config page & save config
+   */
+  protected function displayConfigPage()
+  {
+    $cfg=$this->config;
+
+    if(isset($_POST['submit_save_config']))
+    {
+      foreach($cfg as $key => $val)
+      {
+        if(isset($_REQUEST['f_'.$key]))
+        {
+          $cfg[$key] = $_REQUEST['f_'.$key];
+        }
+      }
+
+      if($cfg['color_r']=='')
+      {
+        $cfg['mode_r']='none';
+      }
+      else
+      {
+        $cfg['mode_r']='line';
+      }
+
+      if($cfg['color_g']=='')
+      {
+        $cfg['mode_g']='none';
+      }
+      else
+      {
+        $cfg['mode_g']='line';
+      }
+
+      if($cfg['color_b']=='')
+      {
+        $cfg['mode_b']='none';
+      }
+      else
+      {
+        $cfg['mode_b']='line';
+      }
+
+      $cfg['color_bg'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_bg']));
+      $cfg['color_v'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_v']));
+      $cfg['color_r'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_r']));
+      $cfg['color_g'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_g']));
+      $cfg['color_b'] = Histogram::RGBToInt(Histogram::StringToRGB($cfg['color_b']));
+
+
+      $this->config=$cfg;
+      $this->purgeHistoCache();
+
+      $this->displayResult(l10n('hgram_save_config'), $this->saveConfig());
+    }
+
+    $this->displayConfig();
+  }
+
+  /**
+   * display config page
+   */
+  protected function displayConfig()
+  {
+    global $template, $lang;
+
+    $template->set_filename('body_page',
+                dirname($this->getFileLocation()).'/admin/hgram_config.tpl');
+
+
+    $cfg=$this->config;
+
+    $cfg['color_bg'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_bg']));
+    $cfg['color_v'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_v']));
+    $cfg['color_r'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_r']));
+    $cfg['color_g'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_g']));
+    $cfg['color_b'] = Histogram::RGBToString(Histogram::IntToRGB($cfg['color_b']));
+    if($cfg['mode_r']=='none') $cfg['color_r']='';
+    if($cfg['mode_g']=='none') $cfg['color_g']='';
+    if($cfg['mode_b']=='none') $cfg['color_b']='';
+
+
+    $template->assign('hgramConfig', $cfg);
+
+    $template->assign_var_from_handle('HGRAM_BODY_PAGE', 'body_page');
+
+  } //displayConfig
+
+
+
+} //class
+
+
+?>
Index: /extensions/Histogram/hgram_ajax.php
===================================================================
--- /extensions/Histogram/hgram_ajax.php	(revision 8509)
+++ /extensions/Histogram/hgram_ajax.php	(revision 8509)
@@ -0,0 +1,127 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  --------------------------------------------------------------------------- */
+
+
+  define('PHPWG_ROOT_PATH',dirname(dirname(dirname(__FILE__))).'/');
+
+  /*
+   * set ajax module in admin mode if request is used for admin interface
+   */
+  if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
+  if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']))
+  {
+    define('IN_ADMIN', true);
+  }
+
+  // the common.inc.php file loads all the main.inc.php plugins files
+  include_once(PHPWG_ROOT_PATH.'include/common.inc.php' );
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
+  include_once('hgram_root.class.inc.php');
+
+  load_language('plugin.lang', HGRAM_PATH);
+
+
+  class HGram_ajax extends HGram_root
+  {
+
+
+    /**
+     * constructor
+     */
+    public function __construct($prefixeTable, $filelocation)
+    {
+      parent::__construct($prefixeTable, $filelocation);
+      $this->loadConfig();
+      $this->checkRequest();
+      $this->returnAjaxContent();
+    }
+
+    /**
+     * check the $_REQUEST values and set default values
+     *
+     */
+    protected function checkRequest()
+    {
+      global $user;
+
+      if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
+
+      // check if asked function is valid
+      if(!(
+           $_REQUEST['ajaxfct']=='public.histo.build'
+          )
+        ) $_REQUEST['ajaxfct']='';
+
+
+      if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']) and !is_admin()) $_REQUEST['ajaxfct']='';
+
+      // check token validity
+      if(!isset($_REQUEST['token'])) $_REQUEST['token']='';
+
+
+
+      if($_REQUEST['ajaxfct']!='')
+      {
+        /*
+         * check public.histo.build
+         */
+        if($_REQUEST['ajaxfct']=="public.histo.build")
+        {
+          if(!isset($_REQUEST['id'])) $_REQUEST['ajaxfct']='';
+          if($_REQUEST['token']!=self::getToken($_REQUEST['id'])) $_REQUEST['ajaxfct']='';
+        }
+      }
+    }
+
+
+    /**
+     * return ajax content
+     */
+    protected function returnAjaxContent()
+    {
+      $result="<p class='errors'>An error has occured</p>";
+      switch($_REQUEST['ajaxfct'])
+      {
+        case 'public.histo.build':
+          $result=$this->ajax_hgram_public_histoBuild($_REQUEST['id']);
+          break;
+      }
+      GPCAjax::returnResult($result);
+    }
+
+
+    /*------------------------------------------------------------------------*
+     *
+     * PUBLIC FUNCTIONS
+     *
+     *----------------------------------------------------------------------- */
+    private function ajax_hgram_public_histoBuild($imageId)
+    {
+      return(self::getHistogramGraph($imageId, true));
+    }
+
+
+
+    /*------------------------------------------------------------------------*
+     *
+     * ADMIN FUNCTIONS
+     *
+     *----------------------------------------------------------------------- */
+
+
+
+  } //class
+
+
+  $returned=new HGram_ajax($prefixeTable, __FILE__);
+?>
Index: /extensions/Histogram/hgram_histogram.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_histogram.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_histogram.class.inc.php	(revision 8509)
@@ -0,0 +1,378 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@grum.fr
+    website  : http://photos.grum.fr
+    PWG user : http://forum.piwigo.org/profile.php?id=3706
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  Provided classes :
+
+
+  --------------------------------------------------------------------------- */
+
+if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+
+class Histogram {
+  static public $fileHistogram = Array(
+    'pixels' => 0,
+    'analyzed' => 0,
+    'time' => 0,
+    'fileName' => "",
+  );
+
+  /**
+   * returns histogram values for an image
+   *
+   *
+   * @param String $fileName : the picture's filename
+   * @return : -1 if file doesn't exist
+   *           -2 if file is not a PNG, a JPEG or a GIF file
+   *           -3 if a fatal error occurs
+   *            Array of L, R, G, and B values (% for values from 0 to 255)
+   */
+  static function read($fileName)
+  {
+    self::$fileHistogram=Array(
+      'pixels'   => 0,
+      'analyzed' => 0,
+      'time' => 0,
+      'pps' =>0,
+    );
+
+    $returned=array(
+      'L' => array(),
+      'A' => array(),
+      'M' => array(),
+      'R' => array(),
+      'G' => array(),
+      'B' => array()
+    );
+
+    for($i=0;$i<256;$i++)
+    {
+      $returned['L'][$i]=0;
+      $returned['A'][$i]=0;
+      $returned['M'][$i]=0;
+      $returned['R'][$i]=0;
+      $returned['G'][$i]=0;
+      $returned['B'][$i]=0;
+    }
+
+    if(file_exists($fileName))
+    {
+      $time=microtime(true);
+
+      try
+      {
+        if(preg_match('/.*\.gif$/i', $fileName))
+        {
+          $image = imagecreatefromgif($fileName);
+        }
+        elseif(preg_match('/.*\.(jpg|jpeg)$/i', $fileName))
+        {
+          $image = imagecreatefromjpeg($fileName);
+        }
+        elseif(preg_match('/.*\.png$/i', $fileName))
+        {
+          $image = imagecreatefrompng($fileName);
+        }
+        else
+        {
+          return(-2);
+        }
+
+        $imageWidth=imagesx($image);
+        $imageHeight=imagesy($image);
+
+        $i=0;
+        for($px=0;$px<$imageWidth;$px++)
+        {
+          for($py=0;$py<$imageHeight;$py++)
+          {
+            $i++;
+            $value=imagecolorat($image, $px, $py);
+
+            $rgb=self::IntToRGB($value);
+            $l=self::RGBtoL($rgb);
+            $a=self::RGBtoA($rgb);
+            $m=self::RGBtoM($rgb);
+
+            $returned['L'][$l]++;
+            $returned['A'][$a]++;
+            $returned['M'][$m]++;
+            $returned['R'][$rgb['R']]++;
+            $returned['G'][$rgb['G']]++;
+            $returned['B'][$rgb['B']]++;
+
+            unset($rgb);
+          }
+        }
+
+        imagedestroy($image);
+
+        self::$fileHistogram=Array(
+          'pixels'   => $imageWidth*$imageHeight,
+          'analyzed' => $i,
+          'time'     => microtime(true)-$time,
+          'pps'      => $i/(microtime(true)-$time),
+        );
+
+        ksort($returned['L']);
+        ksort($returned['A']);
+        ksort($returned['M']);
+        ksort($returned['R']);
+        ksort($returned['G']);
+        ksort($returned['B']);
+
+        foreach($returned as $key => $val)
+        {
+          $m=max($returned[$key]);
+          foreach($returned[$key] as $key2 => $val2)
+          {
+            $returned[$key][$key2]=round($val2/$m,4);
+          }
+        }
+
+        return($returned);
+      }
+      catch (Exception $e)
+      {
+        //echo "ERROR!<br>".print_r($e, true);
+        return(-3);
+      }
+    }
+    else
+    {
+      return(-1);
+    }
+  }
+
+
+  /**
+   * build the histogram and save it in an image file
+   *
+   * @param String $fileName : the histogram filename
+   * @param Array $values : array('L', 'R', 'G', 'B') of values
+   * @param Array $options : array of options for histogram rendering
+   *                'color_bg' : background color
+   *                'color_l'  : color for luminance drawing
+   *                'color_r'  : color for red drawing
+   *                'color_g'  : color for green drawing
+   *                'color_b'  : color for blue drawing
+   *                'color_ticks'  : color for ticks drawing
+   *                'mode_l'   : drawing mode for luminance
+   *                'mode_r'   : drawing mode for luminance
+   *                'mode_g'   : drawing mode for luminance
+   *                'mode_b'   : drawing mode for luminance
+   *                  => modes can takes 'line' or 'bar' or 'surface' or 'none' values
+   *                'mode_ticks_h' : drawing mode for horizontal ticks
+   *                'mode_ticks_v' : drawing mode for vertical ticks
+   *                  => can takes 'none' or 'dot' or 'solid'
+   *                'histo_width' : histogram width
+   *                'histo_height' : histogram height
+   */
+  static function build($fileName, $values, $options=array())
+  {
+    $options=self::checkHistoOptions($options);
+
+    $image=imagecreatetruecolor($options['histo_width'], $options['histo_height']);
+    $options['color_bg']=self::colorAllocate($image, $options['color_bg']);
+    $options['color_l']=self::colorAllocate($image, $options['color_l']);
+    $options['color_r']=self::colorAllocate($image, $options['color_r']);
+    $options['color_g']=self::colorAllocate($image, $options['color_g']);
+    $options['color_b']=self::colorAllocate($image, $options['color_b']);
+
+    imagefilledrectangle($image,0,0,$options['histo_width'], $options['histo_height'], $options['color_bg']);
+
+
+    $histoList=array('l', 'r', 'g', 'b');
+
+
+    foreach($histoList as $histo)
+    {
+      switch($options['mode_'.$histo])
+      {
+        case 'line':
+        case 'surface':
+          $points=array(0,$options['histo_height']);
+          if($histo=='l')
+          {
+            $histoKey=$options['histo_method'];
+          }
+          else
+          {
+            $histoKey=$histo;
+          }
+
+          foreach($values[strtoupper($histoKey)] as $key => $histoValue)
+          {
+            $points[]=$key * $options['histo_width']/255;
+            $points[]=$options['histo_height'] - $histoValue * $options['histo_height'];
+          }
+          $points[]=$options['histo_width'];
+          $points[]=$options['histo_height'];
+
+          if($options['mode_'.$histo]=='line')
+          {
+            imagepolygon($image,$points, count($points)/2, $options['color_'.$histo]);
+          }
+          else
+          {
+            imagefilledpolygon($image,$points, count($points)/2, $options['color_'.$histo]);
+          }
+          break;
+        case 'bar':
+          break;
+      }
+    }
+
+    imagepng($image, $fileName);
+    imagedestroy($image);
+  }
+
+
+  /**
+   *  Calculate the Luminance value from a RGB value
+   *
+   * @param Array $RGB : RGB object
+   * @return Integer : luminance color
+   */
+  static public function RGBtoL($RGB)
+  {
+    return(round($RGB['R']*0.299+$RGB['G']*0.587+$RGB['B']*0.114,0));
+  }
+
+  /**
+   *  Calculate the average grey value from a RGB value
+   *
+   * @param Array $RGB : RGB object
+   * @return Integer : average grey color
+   */
+  static public function RGBtoA($RGB)
+  {
+    return(round(($RGB['R']+$RGB['G']+$RGB['B'])/3,0));
+  }
+
+
+  /**
+   *  Calculate the max value from a RGB value
+   *
+   * @param Array $RGB : RGB object
+   * @return Integer : the max value
+   */
+  static public function RGBtoM($RGB)
+  {
+    return(max($RGB));
+  }
+
+
+  /**
+   *
+   * @param Int $rgb : an integer &hRRGGBB
+   * @return RGB : a RGB object
+   */
+  static public function IntToRGB($rgb)
+  {
+    return(
+      Array(
+        'R' => ($rgb >> 16) & 0xFF,
+        'G' => ($rgb >> 8) & 0xFF,
+        'B' => $rgb & 0xFF
+      )
+    );
+  }
+
+  /**
+   * convert a string like #rrggbb into a RGB array
+   *
+   * @param String $rgb : a #rrggbb string
+   * @return Array
+   */
+  static public function StringToRGB($rgb)
+  {
+    $returned=array(
+      'R' => 0,
+      'G' => 0,
+      'B' => 0
+    );
+
+    if(preg_match_all('/^#([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})$/i', $rgb, $values, PREG_SET_ORDER)>0)
+    {
+      $returned['R']=intval('0x'.$values[0][1],0);
+      $returned['G']=intval('0x'.$values[0][2],0);
+      $returned['B']=intval('0x'.$values[0][3],0);
+    }
+
+    return($returned);
+  }
+
+  /**
+   * convert a RGB array ('R'=>r, 'G'=>g, 'B'=>b ) into integer value
+   *
+   * @param Array $rgb : rgb array
+   * @return Integer
+   */
+  static public function RGBToInt($rgb)
+  {
+    return($rgb['R']*65536 + $rgb['G']*256 + $rgb['B']);
+  }
+
+  /**
+   * convert a RGB array ('R'=>r, 'G'=>g, 'B'=>b ) into string #rrggbb value
+   *
+   * @param Array $rgb : rgb array
+   * @return String
+   */
+  static public function RGBToString($rgb)
+  {
+    return(
+      sprintf('#%02X%02X%02X', $rgb['R'], $rgb['G'], $rgb['B'])
+    );
+  }
+
+  static public function checkHistoOptions($options)
+  {
+    if(!isset($options['color_bg']) or !is_numeric($options['color_bg'])) $options['color_bg']=0xffffff;
+    if(!isset($options['color_l']) or !is_numeric($options['color_l'])) $options['color_l']=0x808080;
+    if(!isset($options['color_r']) or !is_numeric($options['color_r'])) $options['color_r']=0xA00000;
+    if(!isset($options['color_g']) or !is_numeric($options['color_g'])) $options['color_g']=0x00A000;
+    if(!isset($options['color_b']) or !is_numeric($options['color_b'])) $options['color_b']=0x0000A0;
+
+    $modes=array('surface', 'line', 'bar', 'none');
+    if(!isset($options['mode_l']) or !in_array($options['mode_l'], $modes)) $options['mode_l']='surface';
+    if(!isset($options['mode_r']) or !in_array($options['mode_l'], $modes)) $options['mode_r']='line';
+    if(!isset($options['mode_g']) or !in_array($options['mode_l'], $modes)) $options['mode_g']='line';
+    if(!isset($options['mode_b']) or !in_array($options['mode_l'], $modes)) $options['mode_b']='line';
+
+    if(!isset($options['histo_width']) or !is_numeric($options['histo_width']) or $options['histo_width']<=0) $options['histo_width']=256;
+    if(!isset($options['histo_height']) or !is_numeric($options['histo_height']) or $options['histo_height']<=0) $options['histo_height']=100;
+    if(!isset($options['histo_method']) or !in_array($options['histo_method'], array('L', 'A', 'M'))) $options['histo_method']='L';
+
+    return($options);
+  }
+
+
+  static public function colorAllocate($im, $color)
+  {
+    $rgb=self::IntToRGB($color);
+    return(imagecolorallocate($im, $rgb['R'], $rgb['G'], $rgb['B']));
+  }
+
+  static public function colorAllocateA($im, $color, $alpha)
+  {
+    $rgb=self::IntToRGB($color);
+    return(imagecolorallocatealpha($im, $rgb['R'], $rgb['G'], $rgb['B'], $alpha));
+  }
+
+
+}
+
+
+?>
Index: /extensions/Histogram/hgram_install.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_install.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_install.class.inc.php	(revision 8509)
@@ -0,0 +1,111 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  HGram_Install : classe to manage plugin install
+
+  --------------------------------------------------------------------------- */
+
+  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+  include_once('hgram_version.inc.php'); // => Don't forget to update this file !!
+  include_once('hgram_root.class.inc.php');
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
+
+  /* HGram class for install process */
+  class HGram_Install extends HGram_root
+  {
+    private $tablef;
+
+    public function __construct($prefixeTable, $filelocation)
+    {
+      parent::__construct($prefixeTable, $filelocation);
+      $this->tablef= new GPCTables($this->tables);
+    }
+
+    public function __destruct()
+    {
+      unset($this->tablef);
+      parent::__destruct();
+    }
+
+    /*
+        function for installation process
+        return true if install process is ok, otherwise false
+    */
+    public function install()
+    {
+      if(!file_exists(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY))
+      {
+        mkdir(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY, 0755, true);
+      }
+
+      $this->initConfig();
+      $this->loadConfig();
+      $this->config['installed']=HGRAM_VERSION2;
+      $this->config['newInstall']='y';
+      $this->saveConfig();
+
+      $tables_def=array(
+"CREATE TABLE `".$this->tables['histo']."` (
+  `imageId` INTEGER UNSIGNED NOT NULL DEFAULT 0,
+  `valueL` VARCHAR(1792)  NOT NULL,
+  `valueA` VARCHAR(1792)  NOT NULL,
+  `valueM` VARCHAR(1792)  NOT NULL,
+  `valueR` VARCHAR(1792)  NOT NULL,
+  `valueG` VARCHAR(1792)  NOT NULL,
+  `valueB` VARCHAR(1792)  NOT NULL,
+  `graphFile` VARCHAR(36)  NOT NULL,
+  PRIMARY KEY (`imageId`)
+)
+CHARACTER SET utf8 COLLATE utf8_general_ci",
+      );
+
+      $result=$this->tablef->create($tables_def);
+
+      GPCCore::register($this->getPluginName(), HGRAM_VERSION, HGRAM_GPC_NEEDED);
+
+      return($result);
+    }
+
+
+    /*
+        function for uninstall process
+    */
+    public function uninstall()
+    {
+      GPCCore::unregister($this->getPluginName());
+
+      $this->purgeHistoCache();
+
+      $this->deleteConfig();
+      $this->tablef->drop();
+      return('');
+    }
+
+    public function activate()
+    {
+      global $template;
+
+      $this->initConfig();
+      $this->loadConfig();
+      $this->config['installed']=HGRAM_VERSION2;
+      $this->saveConfig();
+
+      return('');
+    }
+
+    public function deactivate()
+    {
+    }
+
+  } //class
+
+?>
Index: /extensions/Histogram/hgram_pip.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_pip.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_pip.class.inc.php	(revision 8509)
@@ -0,0 +1,94 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  HGram_PIP : classe to manage plugin public pages
+
+  --------------------------------------------------------------------------- */
+
+include_once('hgram_root.class.inc.php');
+
+class HGram_PIP extends HGram_root
+{
+  protected $section_page;
+
+  public function __construct($prefixeTable, $filelocation)
+  {
+    parent::__construct($prefixeTable, $filelocation);
+    $this->loadConfig();
+
+    $this->initEvents();
+    $this->load_lang();
+  }
+
+  public function __destruct()
+  {
+    unset($section_page);
+    parent::__destruct();
+  }
+
+  /**
+   * load language file
+   */
+  public function load_lang()
+  {
+    global $lang;
+
+    load_language('plugin.lang', HGRAM_PATH);
+  }
+
+  /**
+   * initialize events call for the plugin
+   */
+  public function initEvents()
+  {
+    parent::initEvents();
+
+    add_event_handler('loc_begin_picture', array(&$this, 'addHistogram'));
+  }
+
+
+
+  /* -------------------------------------------------------------------------
+    FUNCTIONS TO MANAGE HISTOGRAM DISPLAY
+  ------------------------------------------------------------------------- */
+  public function addHistogram()
+  {
+    global $page, $template;
+
+    $fileName=self::getHistogramGraph($page['image_id']);
+
+    $metadata=$template->get_template_vars('metadata');
+
+
+    $template->set_filename('hgramHisto',
+                dirname($this->getFileLocation()).'/templates/hgram_picture_histo.tpl');
+    $template->assign('histoImg', $fileName);
+    $template->assign('imageId', $page['image_id']);
+    $template->assign('token', self::getToken($page['image_id']));
+
+
+
+    $histoNfo=Array(
+      'TITLE' => l10n('hgram_histogram'),
+      'lines' => Array(
+        '<!--rawContent-->' => $template->parse('hgramHisto', true)
+      )
+    );
+
+    $metadata[]=$histoNfo;
+
+    $template->assign('metadata', $metadata);
+  }
+
+
+} //class
+
+?>
Index: /extensions/Histogram/hgram_root.class.inc.php
===================================================================
--- /extensions/Histogram/hgram_root.class.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_root.class.inc.php	(revision 8509)
@@ -0,0 +1,247 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  HGram_root : common classe for admin and public classes
+
+  --------------------------------------------------------------------------- */
+
+  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+  include_once('hgram_histogram.class.inc.php');
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
+
+  class HGram_root extends CommonPlugin
+  {
+    const LOCAL_DIRECTORY='/local/plugins/Histogram/';
+
+    static public $pluginName='Histogram';
+    static public $pluginNameFile='hgram';
+    static public $pluginTables=array('histo');
+
+    protected $css;   //the css object
+
+    public function __construct($prefixeTable, $filelocation)
+    {
+      $this->setPluginName(self::$pluginName);
+      $this->setPluginNameFiles(self::$pluginNameFile);
+      parent::__construct($prefixeTable, $filelocation);
+      $this->section_name=$this->getPluginNameFiles();
+
+      $this->setTablesList(self::$pluginTables);
+
+
+      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
+    }
+
+    public function __destruct()
+    {
+      unset($this->css);
+      parent::__destruct();
+    }
+
+    public function initEvents()
+    {
+      parent::initEvents();
+      add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
+    }
+
+    /**
+     * menu block management
+     */
+    public function register_blocks()
+    {
+    }
+
+    /**
+     * initialize default values
+     *
+     */
+    public function initConfig()
+    {
+      $this->config=array(
+        'histo_width'  => 256,
+        'histo_height' => 100,
+        'histo_method' => 'L',  // L:luminance, A:average, M:max
+        'color_bg' => 0xffffff,
+        'color_v'  => 0x606060,
+        'color_r'  => 0xC00000,
+        'color_g'  => 0x00C000,
+        'color_b'  => 0x0000C0,
+        'mode_v'   => 'surface',
+        'mode_r'   => 'line',
+        'mode_g'   => 'line',
+        'mode_b'   => 'line'
+      );
+    }
+
+    /**
+     * check if the given picture as histogram values
+     *
+     * @param Integer $id : piwigo image id
+     * @return Bool : true if histogram exists
+     */
+    public function checkHistogram($id)
+    {
+      $sql="SELECT COUNT(imageId) FROM ".$this->tables['histo']."
+            WHERE imageId='$id';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        $count=0;
+        while($row=pwg_db_fetch_row($result))
+        {
+          $count=$row[0];
+        }
+        return($count>0);
+      }
+      return(false);
+    }
+
+    public function readHistogram($id)
+    {
+      $sql="SELECT path FROM ".IMAGES_TABLE."
+            WHERE id='$id';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $fileName=GPCCore::getPiwigoSystemPath().'/'.$row['path'];
+        }
+
+        if(file_exists($fileName))
+        {
+          $values=Histogram::read($fileName);
+
+          $sql="REPLACE INTO ".$this->tables['histo']." VALUES ('$id', '".implode(';',$values['L'])."', '".implode(';',$values['A'])."', '".implode(';',$values['M'])."', '".implode(';',$values['R'])."', '".implode(';',$values['G'])."', '".implode(';',$values['B'])."', '')";
+          $result=pwg_query($sql);
+        }
+      }
+    }
+
+    public function getHistogram($id)
+    {
+      $returned=array(
+        'L' => array(),
+        'A' => array(),
+        'M' => array(),
+        'R' => array(),
+        'G' => array(),
+        'B' => array()
+      );
+      $sql="SELECT valueL AS L, valueA AS A, valueM AS M, valueR AS R, valueG AS G, valueB AS B
+            FROM ".$this->tables['histo']."
+            WHERE imageId='$id';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $returned['L']=explode(';', $row['L']);
+          $returned['A']=explode(';', $row['A']);
+          $returned['M']=explode(';', $row['M']);
+          $returned['R']=explode(';', $row['R']);
+          $returned['G']=explode(';', $row['G']);
+          $returned['B']=explode(';', $row['B']);
+        }
+      }
+
+      return($returned);
+    }
+
+
+    public function getHistogramGraph($id, $read=false)
+    {
+      $sql="SELECT graphFile FROM ".$this->tables['histo']."
+            WHERE imageId='$id';";
+      $result=pwg_query($sql);
+      if($result)
+      {
+        $fileName='';
+        $exist=false;
+        while($row=pwg_db_fetch_assoc($result))
+        {
+          $fileName=$row['graphFile'];
+          $exist=true;
+        }
+
+        if(!$exist)
+        {
+          if($read)
+          {
+            self::readHistogram($id);
+          }
+          else
+          {
+            return('');
+          }
+        }
+
+        if($fileName=='' or !file_exists(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY.$fileName))
+        {
+          $fileName=md5(
+            sprintf("%s-%s",
+              $id,
+              implode('-', $this->config)
+            )
+          ).".png";
+
+          $values=self::getHistogram($id);
+
+          Histogram::build(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY.$fileName, $values, $this->config);
+
+          $sql="UPDATE ".$this->tables['histo']."
+                SET graphFile='$fileName'
+                WHERE imageId='$id';";
+          pwg_query($sql);
+        }
+
+        return($fileName);
+      }
+      return('');
+    }
+
+    /**
+     * get a valid token for an image (used to build histogram)
+     *
+     * @param Integer $imageId : image id
+     * @return String : valid token
+     */
+    public function getToken($imageId)
+    {
+      global $conf;
+      return(hash_hmac('md5', "$imageId-".session_id(), $conf['secret_key']));
+    }
+
+    /**
+     * purge all histogram graph in directory cache
+     */
+    public function purgeHistoCache()
+    {
+      $files=scandir(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY);
+      foreach($files as $fileName)
+      {
+        if(!is_dir($fileName)) unlink(GPCCore::getPiwigoSystemPath().self::LOCAL_DIRECTORY.'/'.$fileName);
+      }
+
+      $sql="UPDATE ".$this->tables['histo']."
+            SET graphFile='';";
+      pwg_query($sql);
+    }
+
+
+  } //class
+
+
+?>
Index: /extensions/Histogram/hgram_version.inc.php
===================================================================
--- /extensions/Histogram/hgram_version.inc.php	(revision 8509)
+++ /extensions/Histogram/hgram_version.inc.php	(revision 8509)
@@ -0,0 +1,20 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@grum.fr
+    website  : http://photos.grum.fr
+    PWG user : http://forum.piwigo.org/profile.php?id=3706
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  --------------------------------------------------------------------------- */
+
+  if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+  define('HGRAM_VERSION',  '0.1.0');
+  define('HGRAM_VERSION2', '00.01.00');
+  define('HGRAM_GPC_NEEDED', '3.2.0');
+?>
Index: /extensions/Histogram/index.php
===================================================================
--- /extensions/Histogram/index.php	(revision 8509)
+++ /extensions/Histogram/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Histogram/js/histoLoad.js
===================================================================
--- /extensions/Histogram/js/histoLoad.js	(revision 8509)
+++ /extensions/Histogram/js/histoLoad.js	(revision 8509)
@@ -0,0 +1,27 @@
+
+function HistoLoad()
+{
+  var get = function(id, token)
+  {
+    $.ajax(
+      {
+        type: "POST",
+        url: "plugins/Histogram/hgram_ajax.php",
+        async: true,
+        data: { ajaxfct:"public.histo.build", id:id, token:token },
+        success:
+          function(msg)
+          {
+            if(msg!='')
+            {
+              $('#iHistoTxt').remove();
+              $('#iHistoContent').append('<img id="#iHistoImg" src="local/plugins/Histogram/'+msg+'">');
+            }
+          }
+      }
+    );
+  };
+
+  this.get = function (id, token) { get(id, token); }
+}
+
Index: /extensions/Histogram/js/index.php
===================================================================
--- /extensions/Histogram/js/index.php	(revision 8509)
+++ /extensions/Histogram/js/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Histogram/language/en_UK/description.txt
===================================================================
--- /extensions/Histogram/language/en_UK/description.txt	(revision 8509)
+++ /extensions/Histogram/language/en_UK/description.txt	(revision 8509)
@@ -0,0 +1,1 @@
+Allows to display picture's histogram
Index: /extensions/Histogram/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/Histogram/language/en_UK/plugin.lang.php	(revision 8509)
+++ /extensions/Histogram/language/en_UK/plugin.lang.php	(revision 8509)
@@ -0,0 +1,27 @@
+<?php
+
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before']="To install this plugin, you need to install Grum Plugin Classes %s before";
+
+$lang['hgram_release']='v';
+
+$lang['hgram_config']='Configuration';
+$lang['hgram_histosize']='Size';
+$lang['hgram_width']='Width';
+$lang['hgram_height']='Height';
+$lang['hgram_method']='Computing method (main histogram)';
+$lang['hgram_luminance']='Luminance';
+$lang['hgram_average']='Average';
+$lang['hgram_max']='Maximum';
+$lang['hgram_like_photoshop']='like Adobe Photoshop does';
+$lang['hgram_like_gimp']='like The Gimp does';
+$lang['hgram_bg_color']='Couleur de fond';
+$lang['hgram_global_color']="Color for the main histogram";
+$lang['hgram_red_color']="Color for the red histogram";
+$lang['hgram_green_color']="Color for the green histogram";
+$lang['hgram_blue_color']="Color for the blue histogram";
+$lang['hgram_apply']='Apply';
+$lang['hgram_histogram']='Histogram';
+$lang['hgram_save_config']="Configuration saved";
+
+
+?>
Index: /extensions/Histogram/language/fr_FR/description.txt
===================================================================
--- /extensions/Histogram/language/fr_FR/description.txt	(revision 8509)
+++ /extensions/Histogram/language/fr_FR/description.txt	(revision 8509)
@@ -0,0 +1,1 @@
+Permet d'afficher l'histogramme d'une image
Index: /extensions/Histogram/language/fr_FR/index.php
===================================================================
--- /extensions/Histogram/language/fr_FR/index.php	(revision 8509)
+++ /extensions/Histogram/language/fr_FR/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Histogram/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Histogram/language/fr_FR/plugin.lang.php	(revision 8509)
+++ /extensions/Histogram/language/fr_FR/plugin.lang.php	(revision 8509)
@@ -0,0 +1,27 @@
+<?php
+
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before']="Pour installer ce plugin, vous devez au préalable installer le plugin Grum Plugin Classes %s";
+
+$lang['hgram_release']='v';
+
+$lang['hgram_config']='Configuration';
+$lang['hgram_histosize']='Dimensions';
+$lang['hgram_width']='Largeur';
+$lang['hgram_height']='Hauteur';
+$lang['hgram_method']='Méthode de calcul (histogramme principal)';
+$lang['hgram_luminance']='Luminance';
+$lang['hgram_average']='Moyenne';
+$lang['hgram_max']='Maximum';
+$lang['hgram_like_photoshop']='méthode similaire à Adobe Photoshop';
+$lang['hgram_like_gimp']='méthode similaire à The Gimp';
+$lang['hgram_bg_color']='Couleur de fond';
+$lang['hgram_global_color']="Couleur de l'histogramme principal";
+$lang['hgram_red_color']="Couleur de l'histogramme rouge";
+$lang['hgram_green_color']="Couleur de l'histogramme vert";
+$lang['hgram_blue_color']="Couleur de l'histogramme bleu";
+$lang['hgram_apply']='Appliquer';
+$lang['hgram_histogram']='Histogramme';
+$lang['hgram_save_config']="Configuration sauvegardée";
+
+
+?>
Index: /extensions/Histogram/language/index.php
===================================================================
--- /extensions/Histogram/language/index.php	(revision 8509)
+++ /extensions/Histogram/language/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/Histogram/main.inc.php
===================================================================
--- /extensions/Histogram/main.inc.php	(revision 8509)
+++ /extensions/Histogram/main.inc.php	(revision 8509)
@@ -0,0 +1,85 @@
+<?php
+/*
+Plugin Name: Histogram
+Version: 0.1.0
+Description: Allow to make stat on pictures colors
+Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=393
+Author: grum@piwigo.org
+Author URI: http://photos.grum.fr
+*/
+
+/*
+--------------------------------------------------------------------------------
+  Author     : Grum
+    email    : grum@piwigo.com
+    website  : http://photos.grum.fr
+    PWG user : http://forum.phpwebgallery.net/profile.php?id=3706
+
+    << May the Little SpaceFrog be with you ! >>
+--------------------------------------------------------------------------------
+
+:: HISTORY
+
+| release | date       |
+| 0.1.0   | 2011/01/07 | * start to coding
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+
+
+:: TO DO
+
+--------------------------------------------------------------------------------
+
+:: NFO
+  HGram_root : common classe for admin and public classes
+  HGram_AIM  : classe to manage plugin integration into plugin menu
+  HGram_AIP  : classe to manage plugin admin pages
+  HGram_PIP  : classe to manage plugin public pages
+
+--------------------------------------------------------------------------------
+*/
+
+// pour faciliter le debug :o)
+ //ini_set('error_reporting', E_ALL);
+ //ini_set('display_errors', true);
+
+if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+
+define('HGRAM_DIR' , basename(dirname(__FILE__)));
+define('HGRAM_PATH' , PHPWG_PLUGINS_PATH . HGRAM_DIR . '/');
+
+include_once('hgram_version.inc.php'); // => Don't forget to update this file !!
+
+global $prefixeTable;
+
+if(defined('IN_ADMIN'))
+{
+  // HGram admin interface loaded and active only if in admin page
+  include_once("hgram_aim.class.inc.php");
+  $obj=new HGram_AIM($prefixeTable, __FILE__);
+  $obj->initEvents();
+  set_plugin_data($plugin['id'], $obj);
+}
+else
+{
+  // HGram public interface loaded and active only if in public page
+  include_once("hgram_pip.class.inc.php");
+  $obj=new HGram_PIP($prefixeTable, __FILE__);
+  set_plugin_data($plugin['id'], $obj);
+}
+
+
+
+?>
Index: /extensions/Histogram/maintain.inc.php
===================================================================
--- /extensions/Histogram/maintain.inc.php	(revision 8509)
+++ /extensions/Histogram/maintain.inc.php	(revision 8509)
@@ -0,0 +1,132 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : Histogram
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+  --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+if(!defined('HGRAM_DIR')) define('HGRAM_DIR' , basename(dirname(__FILE__)));
+if(!defined('HGRAM_PATH')) define('HGRAM_PATH' , PHPWG_PLUGINS_PATH . HGRAM_DIR . '/');
+
+//ini_set('error_reporting', E_ALL);
+//ini_set('display_errors', true);
+
+global $gpcInstalled, $lang; //needed for plugin manager compatibility
+
+/*
+ * -----------------------------------------------------------------------------
+ * Histogram needs the Grum Plugin Classes
+ * -----------------------------------------------------------------------------
+ */
+$gpcInstalled=false;
+if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
+{
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+  // need GPC release greater or equal than 3.2.0
+  if(CommonPlugin::checkGPCRelease(3,2,0))
+  {
+    include_once('hgram_install.class.inc.php');
+    $gpcInstalled=true;
+  }
+}
+
+function gpcMsgError(&$errors)
+{
+  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), HGRAM_GPC_NEEDED);
+  if(is_array($errors))
+  {
+    array_push($errors, $msg);
+  }
+  else
+  {
+    $errors=Array($msg);
+  }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+load_language('plugin.lang', HGRAM_PATH);
+
+
+function plugin_install($plugin_id, $plugin_version, &$errors)
+{
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $hgram = new HGram_Install($prefixeTable, __FILE__);
+    if(!$hgram->install())
+    {
+      array_push($errors, "error");
+    }
+  }
+  else
+  {
+    gpcMsgError($errors);
+  }
+}
+
+function plugin_activate($plugin_id, $plugin_version, &$errors)
+{
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $hgram = new HGram_Install($prefixeTable, __FILE__);
+    $result=$hgram->activate();
+    if($result===false or $result!='')
+    {
+      if(is_string($result))
+      {
+        array_push($errors, $result);
+      }
+      else
+      {
+        array_push($errors, "");
+      }
+    }
+  }
+  else
+  {
+    gpcMsgError($errors);
+  }
+}
+
+function plugin_deactivate($plugin_id)
+{
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $hgram = new HGram_Install($prefixeTable, __FILE__);
+    $hgram->deactivate();
+  }
+}
+
+function plugin_uninstall($plugin_id)
+{
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $hgram = new HGram_Install($prefixeTable, __FILE__);
+    $hgram->uninstall();
+  }
+  else
+  {
+    gpcMsgError($errors);
+  }
+}
+
+
+?>
Index: /extensions/Histogram/templates/hgram_picture_histo.tpl
===================================================================
--- /extensions/Histogram/templates/hgram_picture_histo.tpl	(revision 8509)
+++ /extensions/Histogram/templates/hgram_picture_histo.tpl	(revision 8509)
@@ -0,0 +1,22 @@
+{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
+
+
+<div id='iHistoContent' style='text-align:center;'>
+{if $histoImg==''}
+  {known_script id="histogram.histoLoad" src=$ROOT_URL|@cat:"plugins/Histogram/js/histoLoad.js"}
+  <span id='iHistoTxt'>{'hgram_loading_histo'|@translate}</span>
+  <script type='text/javascript'>
+    {literal}
+    $(window).load(
+      function ()
+      {
+        histo=new HistoLoad();
+        {/literal}histo.get('{$imageId}', '{$token}');{literal}
+      }
+    );
+    {/literal}
+  </script>
+{else}
+  <img id='iHistoImg' src='./local/plugins/Histogram/{$histoImg}'>
+{/if}
+</div>
Index: /extensions/Histogram/templates/index.php
===================================================================
--- /extensions/Histogram/templates/index.php	(revision 8509)
+++ /extensions/Histogram/templates/index.php	(revision 8509)
@@ -0,0 +1,33 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
