Ignore:
Timestamp:
May 27, 2012, 2:06:02 PM (12 years ago)
Author:
grum
Message:

feature:2640 - Compatibility with Piwigo 2.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Histogram/hgram_histogram.class.inc.php

    r8511 r15346  
    1818if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1919
     20define('MAX_PIXELS_ANALYZED', 1000000);
    2021
    2122
     
    9293        $imageHeight=imagesy($image);
    9394
     95
     96        $ratio=1;
     97        $nbPixels=$imageWidth*$imageHeight;
     98        if($nbPixels>MAX_PIXELS_ANALYZED) $ratio=$nbPixels/MAX_PIXELS_ANALYZED;
     99
     100        $imageWorkWidth=round($imageWidth/$ratio,0);
     101        $imageWorkHeight=round($imageHeight/$ratio,0);
     102        $imageWork=imagecreatetruecolor($imageWorkWidth,$imageWorkHeight);
     103        imagecopyresampled($imageWork, $image, 0, 0, 0, 0, $imageWorkWidth, $imageWorkHeight, $imageWidth, $imageHeight);
     104        //imagecopyresized($imageWork, $image, 0, 0, 0, 0, $imageWorkWidth, $imageWorkHeight, $imageWidth, $imageHeight);
     105        imagedestroy($image);
     106
    94107        $i=0;
    95         for($px=0;$px<$imageWidth;$px++)
    96         {
    97           for($py=0;$py<$imageHeight;$py++)
     108        for($px=0;$px<$imageWorkWidth;$px++)
     109        {
     110          for($py=0;$py<$imageWorkHeight;$py++)
    98111          {
    99112            $i++;
    100             $value=imagecolorat($image, $px, $py);
     113            $value=imagecolorat($imageWork, $px, $py);
    101114
    102115            $rgb=self::IntToRGB($value);
     
    116129        }
    117130
    118         imagedestroy($image);
     131        imagedestroy($imageWork);
    119132
    120133        self::$fileHistogram=Array(
    121           'pixels'   => $imageWidth*$imageHeight,
     134          'pixels'   => $imageWorkWidth*$imageWorkHeight,
    122135          'analyzed' => $i,
    123136          'time'     => microtime(true)-$time,
Note: See TracChangeset for help on using the changeset viewer.