ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 7661


Ignore:
Timestamp:
Jul 10, 2008, 2:59:33 AM (13 years ago)
Author:
ebihara
Message:

キャッシュパスの判定処理を OpenPNE_Img_Cache にまとめた

Location:
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img.php

    r7660 r7661  
    8585        $this->generator->setImageSize($width, $height);
    8686
    87         if (!empty($vars['filename'])) {
    88             $this->setFilename($vars['filename']);
    89         }
    90 
    9187        if (!empty($vars['f'])) {
    9288            $this->generator->setOutputFormat($vars['f']);
     
    9490            $this->generator->setOutputFormat();
    9591        }
     92
     93        if (!empty($vars['filename'])) {
     94            $this->setFilename($vars['filename']);
     95        }
    9696    }
    9797
     
    107107            $this->filename = $filename;
    108108
    109             $pieces = explode('.', $filename);
    110             $this->generator->setSourceFormat(OpenPNE_Img::check_format(array_pop($pieces)));
     109            $this->generator->setFilename($filename);
    111110        }
    112111    }
     
    123122        }
    124123
    125         $this->generator->setCacheFilename($this->filename);
    126124        if ($this->generator->isCacheReadable()) {
    127125            return true;
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Cache.php

    r7660 r7661  
    2626
    2727    /**
     28     * @var string
     29     * @access protected
     30     */
     31    var $suffix;
     32
     33    /**
    2834     * constructor
    2935     *
     
    3642            $this->cache_dir = $options['cache_dir'];
    3743        }
     44
     45        if (!empty($options['suffix'])) {
     46            $this->suffix = $options['suffix'];
     47        }
    3848    }
    3949
     
    4353    }
    4454
    45     function setCacheFullpath($filename)
     55    function setCacheFullpath($filename, $format, $width = 0, $height = 0)
    4656    {
    47         $this->cache_fullpath = $filename;
     57        $path = OpenPNE_Img_Cache::getCachePath($filename, $width, $height, $format, $this->suffix);
     58        $this->cache_fullpath = $this->getCacheDir() . '/' . $path;
    4859    }
    4960
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator.php

    r7659 r7661  
    159159
    160160    /**
    161      * キャッシュ画像のファイルパスを設定する
     161     * 画像のファイルパスを設定する
    162162     *
    163163     * @param string $filename
    164164     */
    165     function setCacheFileName($filename)
    166     {
    167         $path = OpenPNE_Img::get_cache_path($filename, $this->width, $this->height, $this->getOutputFormat());
    168         $this->cache->setCacheFullpath($this->cache->getCacheDir() . '/' . $path);
     165    function setFileName($filename)
     166    {
     167        $ext = array_pop(explode('.', $filename));
     168        $format = OpenPNE_Img::check_format($ext);
     169        $this->setSourceFormat($format);
     170
     171        $this->cache->setCacheFullpath($filename, $this->getOutputFormat(), $this->width, $this->height);
    169172    }
    170173
     
    176179    function setOutputFormat($output_format = '')
    177180    {
    178         if ($output_format) {
    179             $this->output_format = $output_format;
    180         } else {
    181             $this->output_format = $this->getSourceFormat();
    182         }
     181        $this->output_format = $output_format;
    183182    }
    184183
  • OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator/ImageMagick.php

    r7659 r7661  
    1515class OpenPNE_Img_Generator_ImageMagick extends OpenPNE_Img_Generator
    1616{
    17     var $raw_cache_fullpath;
     17    var $raw_cache;
     18
     19    function OpenPNE_Img_Generator_ImageMagick($options = array())
     20    {
     21        require_once 'OpenPNE/Img/Cache.php';
     22
     23        parent::OpenPNE_Img_Generator($options);
     24
     25        $options['suffix'] = '_raw';
     26        $this->raw_cache =& new OpenPNE_Img_Cache($options);
     27    }
    1828
    1929    function getCacheRawImage($filename)
    2030    {
    2131        $this->setRawCacheFullPath($filename);
    22         $raw_cache_fullpath = $this->getRawCacheFullPath();
     32        $raw_cache_fullpath = $this->raw_cache->getCacheFullpath();
    2333
    2434        if (is_readable($raw_cache_fullpath)) {
     
    3848    function setRawCacheFullPath($filename)
    3949    {
    40         $prefix = OPENPNE_IMG_CACHE_PREFIX;
    41 
    4250        $format = $this->getSourceFormat();
    43         $file = $prefix . str_replace('.', '_', $filename) . '.' . $format;
    44         $path = sprintf('%s/w_h_raw/%s', $format, $file);
    45 
    46         $this->raw_cache_fullpath = $this->cache->getCacheDir() . '/' . $path;
    47     }
    48 
    49     function getRawCacheFullPath()
    50     {
    51         return $this->raw_cache_fullpath;
     51        $this->raw_cache->setCacheFullpath($filename, $format);
    5252    }
    5353
    5454    function createRawCache($raw_img)
    5555    {
    56         $raw_cache_fullpath = $this->getRawCacheFullPath();
     56        $raw_cache_fullpath = $this->raw_cache->getCacheFullPath();
    5757        $subdir = dirname($raw_cache_fullpath);
    5858        if (!is_dir($subdir)) {
     
    6060        }
    6161
    62         if ($this->output_format == 'png') {
     62        if ($this->getOutputFormat() == 'png') {
    6363            touch($raw_cache_fullpath);
    6464            $output_gdimg = imagecreatefromstring($raw_img);
     
    8989        $h = intval($this->height);
    9090        $f = escapeshellcmd($this->getOutputFormat());
    91         $path = realpath($this->getRawCacheFullPath());
     91        $path = realpath($this->raw_cache->getCacheFullPath());
    9292
    9393        $command = sprintf('%s %s %dx%d %s %s:-', IMGMAGICK_APP, $opt, $w, $h, $path, $f);
Note: See TracChangeset for help on using the changeset viewer.