Changeset 9187


Ignore:
Timestamp:
2006/11/27 19:11:21 (20 years ago)
Author:
kakinaka
Message:

blank

Location:
temp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • temp/trunk/data/class/SC_Image.php

    r9186 r9187  
    5353 
    5454    // ³ÈÂçΨ¤ò»ØÄꤷ¤Æ²èÁüÊݸ 
    55     function saveResizeImage($file, $zip_scale = 1, $header = false) { 
     55    function saveResizeImage($file, $to_w = 1, $to_h = 1, $header = false) { 
    5656        // ¥Ç¥£¥ì¥¯¥È¥ê¼èÆÀ 
    5757        $dir = dirname($file); 
    5858         
    5959        // ¸µ²èÁü¥µ¥¤¥º¤ò¼èÆÀ 
    60         list($src_w, $src_h) = getimagesize($file); 
    61      
     60        list($from_w, $from_h) = getimagesize($file); 
     61         
     62        // Éý¤Î½Ì¾®Î¨ 
     63        ($to_w < $from_w) ? $wscale = $to_w / $from_w : $wscale = 1; 
     64        // ¹â¤µ¤Î½Ì¾®Î¨ 
     65        ($to_h < $from_h) ? $hscale = $to_h / $from_h : $hscale = 1; 
     66        // ½Ì¾®Î¨¤Ï¾®¤µ¤¤¤Û¤¦¤Ë¤¢¤ï¤»¤ë 
     67        ($wscale < $hscale) ? $scale = $wscale : $scale = $hscale; 
     68 
    6269        // °µ½ÌΨ»ØÄê 
    63         $zip_width = $src_w * $zip_scale; 
    64         $zip_height = $src_h * $zip_scale; 
     70        $zip_width = $from_w * $scale; 
     71        $zip_height = $from_h * $scale; 
    6572         
    6673        // ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¼èÆÀ  
     
    8592                    // °µ½ÌÀè²èÁü 
    8693                    $dst_im = imagecreatetruecolor($zip_width, $zip_height);     
    87                     imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $src_w, $src_h); 
     94                    imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $from_w, $from_h); 
    8895                     
    8996                    // ²èÁü½ÐÎÏ 
     
    102109                    // °µ½ÌÀè²èÁü 
    103110                    $dst_im = imagecreatetruecolor($zip_width, $zip_height);     
    104                     imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $src_w, $src_h); 
     111                    imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $from_w, $from_h); 
    105112                     
    106113                    // ²èÁü½ÐÎÏ 
     
    115122                    // °µ½ÌÀè²èÁü 
    116123                    $dst_im = imagecreatetruecolor($zip_width, $zip_height);     
    117                     imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $src_w, $src_h); 
     124                    imagecopyresampled($dst_im, $src_im, 0, 0, 0,0, $zip_width, $zip_height, $from_w, $from_h); 
    118125 
    119126                    // ²èÁü½ÐÎÏ 
  • temp/trunk/html/test/kakinaka/resize_image.php

    r9184 r9187  
    1010 
    1111//sfprintr(pathinfo($file)); 
    12 $path = $objImage->saveResizeImage($file, 0.5, true); 
     12$path = $objImage->saveResizeImage($file, 100, 100, true); 
    1313 
    1414//sfprintr($path); 
Note: See TracChangeset for help on using the changeset viewer.