示例#1
0
 function init()
 {
     parent::init();
     session_write_close();
     $this->phpimage = $p = new \PHPImage($this->options['url']);
     if ($this->options['width'] == 0 and $this->options['height'] == 0) {
         if ($p->getWidth() > $p->getHeight()) {
             $this->options['width'] = $this->options['max_width'];
             $this->options['height'] = $this->options['width'] * ($p->getHeight() / $p->getWidth());
         } else {
             $this->options['height'] = $this->options['max_height'];
             $this->options['width'] = $this->options['height'] * ($p->getWidth() / $p->getHeight());
         }
     } elseif ($this->options['crop']) {
         $p->crop($this->options['crop_x'], $this->options['crop_y'], $this->options['crop_width'], $this->options['crop_height']);
     }
     $p->resize($this->options['width'], $this->options['height'], false, true, true);
     if ($this->options['mask_added'] == "true" && $this->options['apply_mask'] == "true") {
         $this->phpimage->mask($this->options['mask']);
     }
     // if($this->options['rotation_angle']){
     // 	$p->rotate($this->options['rotation_angle']);
     // }
 }
示例#2
0
文件: resize.php 项目: kus/php-image
<?php

require_once '../src/PHPImage.php';
$image = new PHPImage('./img/benji.jpg');
$image->batchResize('examples/thumb_%dx%d.jpg', array(array(400, 400, true, true), array(200, 400, true, true), array(400, 200, true, true), array(100, 100, true, true)));
$image->resize(100, 100, true, true)->show();
示例#3
0
 function mask($mask_details)
 {
     $url = getcwd() . $mask_details['url'];
     if (!file_exists($url)) {
         $url = dirname(getcwd()) . $mask_details['url'];
         if (!file_exists($url)) {
             return;
         }
     }
     $mask = new PHPImage($url);
     $mask->resize($mask_details['width'], $mask_details['height'], false, true, false);
     $this->imagealphamask($this->getResource(), $mask->getResource(), $mask_details);
 }