Changeset 6997
- Timestamp:
- May 7, 2008, 3:14:32 AM (14 years ago)
- Location:
- OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img.php
r6956 r6997 64 64 $this->generator->setImageSize($width, $height); 65 65 66 if (!empty($vars['filename'])) { 67 $this->setFilename($vars['filename']); 68 } 69 66 70 if (!empty($vars['f'])) { 67 71 $this->generator->setOutputFormat($vars['f']); 68 } 69 70 if (!empty($vars['filename'])) { 71 $this->setFilename($vars['filename']); 72 } else { 73 $this->generator->setOutputFormat(); 72 74 } 73 75 } … … 82 84 if (!preg_match('/[^\.\w]/', $filename)) { 83 85 $this->filename = $filename; 86 87 $pieces = explode('.', $filename); 88 $this->generator->setSourceFormat($this->generator->checkFormatString(array_pop($pieces))); 84 89 } 85 90 } -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator.php
r6957 r6997 18 18 19 19 var $source_format; 20 var $output_format = 'jpg';20 var $output_format; 21 21 22 22 var $cache_dir; … … 103 103 { 104 104 if ($this->getOutputFormat() == 'png') { 105 $this->createCache($raw_img); 105 $gdimg = imagecreatefromstring($raw_img); 106 $this->createCache($gdimg); 106 107 } else { 107 108 $handle = fopen($this->cache_fullpath, 'wb'); … … 183 184 function setCacheFileName($filename) 184 185 { 185 $pieces = explode('.', $filename);186 $this->setSourceFormat($this->checkFormatString(array_pop($pieces)));187 188 186 $prefix = OPENPNE_IMG_CACHE_PREFIX; 189 187 190 188 $format = $this->getOutputFormat(); 191 189 $file = $prefix . str_replace('.', '_', $filename) . '.' . $format; 192 $path = sprintf('%s/w%d_h%d/%s', $format, $this->width, $this->height, $file); 190 if ($this->width && $this->height) { 191 $path = sprintf('%s/w%d_h%d/%s', $format, $this->width, $this->height, $file); 192 } else { 193 $path = sprintf('%s/w_h/%s', $format, $file); 194 } 193 195 194 196 $this->cache_fullpath = $this->cache_dir . '/' . $path; … … 243 245 function getOutputFormat() 244 246 { 245 return $this->checkFormatString($this->output_format); 247 if ($this->output_format) { 248 return $this->checkFormatString($this->output_format); 249 } 250 251 return $this->getSourceFormat(); 246 252 } 247 253 -
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator/GD.php
r6996 r6997 31 31 imageinterlace($source_gdimg, 0); 32 32 } 33 /*34 $s_width = imagesx($source_gdimg);35 $s_height = imagesy($source_gdimg);36 33 37 $o_width = $this->width;38 $o_height = $this->height;39 if (!$o_width) {40 $o_width = $s_width;41 }42 if (!$o_height) {43 $o_height = $s_height;44 }45 46 $this->calcResizedImageSize($o_width, $o_height, $s_width, $s_height);47 */48 34 $s_width = imagesx($source_gdimg); 49 35 $s_height = imagesy($source_gdimg); … … 56 42 if (!$h) { 57 43 $h = $s_height; 58 }59 60 // リサイズの必要がない場合61 if ($s_width <= $w && $s_height <= $h) {62 // 形式変換する場合はGDを通す63 if ($this->source_format != $this->output_format) {64 return $source_gdimg;65 }66 return false;67 44 } 68 45
Note: See TracChangeset
for help on using the changeset viewer.