Changeset 7661
- Timestamp:
- Jul 10, 2008, 2:59:33 AM (13 years ago)
- 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 85 85 $this->generator->setImageSize($width, $height); 86 86 87 if (!empty($vars['filename'])) {88 $this->setFilename($vars['filename']);89 }90 91 87 if (!empty($vars['f'])) { 92 88 $this->generator->setOutputFormat($vars['f']); … … 94 90 $this->generator->setOutputFormat(); 95 91 } 92 93 if (!empty($vars['filename'])) { 94 $this->setFilename($vars['filename']); 95 } 96 96 } 97 97 … … 107 107 $this->filename = $filename; 108 108 109 $pieces = explode('.', $filename); 110 $this->generator->setSourceFormat(OpenPNE_Img::check_format(array_pop($pieces))); 109 $this->generator->setFilename($filename); 111 110 } 112 111 } … … 123 122 } 124 123 125 $this->generator->setCacheFilename($this->filename);126 124 if ($this->generator->isCacheReadable()) { 127 125 return true; -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Cache.php
r7660 r7661 26 26 27 27 /** 28 * @var string 29 * @access protected 30 */ 31 var $suffix; 32 33 /** 28 34 * constructor 29 35 * … … 36 42 $this->cache_dir = $options['cache_dir']; 37 43 } 44 45 if (!empty($options['suffix'])) { 46 $this->suffix = $options['suffix']; 47 } 38 48 } 39 49 … … 43 53 } 44 54 45 function setCacheFullpath($filename )55 function setCacheFullpath($filename, $format, $width = 0, $height = 0) 46 56 { 47 $this->cache_fullpath = $filename; 57 $path = OpenPNE_Img_Cache::getCachePath($filename, $width, $height, $format, $this->suffix); 58 $this->cache_fullpath = $this->getCacheDir() . '/' . $path; 48 59 } 49 60 -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator.php
r7659 r7661 159 159 160 160 /** 161 * キャッシュ画像のファイルパスを設定する161 * 画像のファイルパスを設定する 162 162 * 163 163 * @param string $filename 164 164 */ 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); 169 172 } 170 173 … … 176 179 function setOutputFormat($output_format = '') 177 180 { 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; 183 182 } 184 183 -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator/ImageMagick.php
r7659 r7661 15 15 class OpenPNE_Img_Generator_ImageMagick extends OpenPNE_Img_Generator 16 16 { 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 } 18 28 19 29 function getCacheRawImage($filename) 20 30 { 21 31 $this->setRawCacheFullPath($filename); 22 $raw_cache_fullpath = $this-> getRawCacheFullPath();32 $raw_cache_fullpath = $this->raw_cache->getCacheFullpath(); 23 33 24 34 if (is_readable($raw_cache_fullpath)) { … … 38 48 function setRawCacheFullPath($filename) 39 49 { 40 $prefix = OPENPNE_IMG_CACHE_PREFIX;41 42 50 $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); 52 52 } 53 53 54 54 function createRawCache($raw_img) 55 55 { 56 $raw_cache_fullpath = $this-> getRawCacheFullPath();56 $raw_cache_fullpath = $this->raw_cache->getCacheFullPath(); 57 57 $subdir = dirname($raw_cache_fullpath); 58 58 if (!is_dir($subdir)) { … … 60 60 } 61 61 62 if ($this-> output_format== 'png') {62 if ($this->getOutputFormat() == 'png') { 63 63 touch($raw_cache_fullpath); 64 64 $output_gdimg = imagecreatefromstring($raw_img); … … 89 89 $h = intval($this->height); 90 90 $f = escapeshellcmd($this->getOutputFormat()); 91 $path = realpath($this-> getRawCacheFullPath());91 $path = realpath($this->raw_cache->getCacheFullPath()); 92 92 93 93 $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.