예제 #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
파일: overlay.php 프로젝트: kus/php-image
<?php

require_once '../src/PHPImage.php';
$bg = './img/benji.jpg';
$overlay = './img/paw.png';
$image = new PHPImage();
$image->setDimensionsFromImage($bg);
$image->draw($bg);
$image->draw($overlay, '50%', '75%');
$image->rectangle(40, 40, 120, 80, array(0, 0, 0), 0.5);
$image->setFont('./font/arial.ttf');
$image->setTextColor(array(255, 255, 255));
$image->setStrokeWidth(1);
$image->setStrokeColor(array(0, 0, 0));
$image->text('Hello World!', array('fontSize' => 12, 'x' => 50, 'y' => 50));
$image->text('This is a big sentence with width 200px', array('fontSize' => 60, 'x' => 300, 'y' => 0, 'width' => 200, 'height' => 50, 'alignHorizontal' => 'center', 'alignVertical' => 'center', 'debug' => true));
$image->text('This is a big sentence', array('fontSize' => 60, 'x' => 300, 'y' => 200, 'width' => 200, 'height' => 50, 'alignHorizontal' => 'center', 'alignVertical' => 'center', 'debug' => true));
$image->textBox('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', array('width' => 100, 'fontSize' => 8, 'x' => 50, 'y' => 70));
$image->rectangle(40, 140, 170, 160, array(0, 0, 0), 0.5);
$image->textBox('Auto wrap and scale font size to multiline text box width and height bounds. Vestibulum venenatis risus scelerisque enim faucibus, ac pretium massa condimentum. Curabitur faucibus mi at convallis viverra. Integer nec finibus ligula, id hendrerit felis.', array('width' => 150, 'height' => 140, 'fontSize' => 16, 'x' => 50, 'y' => 150));
$image->show();
예제 #4
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);
 }
예제 #5
0
 function init_old()
 {
     parent::init();
     $options = $this->options;
     // print_r($options);
     // exit;
     if ($options['bold'] and !$options['italic']) {
         if (file_exists(getcwd() . '/epan-components/xShop/templates/fonts/' . $options['font'] . '-Bold.ttf')) {
             $options['font'] = $options['font'] . '-Bold';
         }
         // else
         // $draw->setFontWeight(700);
     }
     if ($options['italic'] and !$options['bold']) {
         if (file_exists(getcwd() . '/epan-components/xShop/templates/fonts/' . $options['font'] . '-Italic.ttf')) {
             $options['font'] = $options['font'] . '-Italic';
         } else {
             $options['font'] = $options['font'] . '-Regular';
         }
     }
     if ($options['italic'] and $options['bold']) {
         if (file_exists(getcwd() . '/epan-components/xShop/templates/fonts/' . $options['font'] . '-BoldItalic.ttf')) {
             $options['font'] = $options['font'] . '-BoldItalic';
         } else {
             $options['font'] = $options['font'] . '-Regular';
         }
     }
     if (!$options['bold'] and !$options['italic']) {
         $options['font'] = $options['font'] . '-Regular';
     }
     $font_path = getcwd() . '/epan-components/xShop/templates/fonts/' . $options['font'] . '.ttf';
     // echo $font_path;
     $p = new \PHPImage($options['desired_width'], 10);
     $p->setFont($font_path);
     $p->setFontSize($options['font_size']);
     $p->textBox($options['text'], array('width' => $options['desired_width'], 'x' => 0, 'y' => 0));
     $size = $p->getTextBoxSize($options['font_size'], 0, $font_path, $p->last_text);
     $new_width = abs($size[0]) + abs($size[2]);
     // distance from left to right
     $new_height = abs($size[1]) + abs($size[5]);
     // distance from top to bottom
     $p1 = new \PHPImage($options['desired_width'], $new_height);
     $p1->setFont($font_path);
     $p1->setFontSize($options['font_size']);
     $p1->setTextColor($p1->hex2rgb($options['text_color']));
     // $p1->setAlignHorizontal('right');
     $p1->textBox($options['text'], array('width' => $new_width, 'x' => 0, 'y' => 0));
     if ($this->options['rotation_angle']) {
         $p1->xRotate($this->options['rotation_angle']);
         // $p1->rotate($this->options['rotation_angle']);
     }
     $this->phpimage = $p1;
     $this->new_height = $new_height;
 }
예제 #6
0
파일: text.php 프로젝트: kus/php-image
<?php

require_once '../src/PHPImage.php';
$bg = './img/benji.jpg';
$image = new PHPImage();
$image->setDimensionsFromImage($bg);
$image->draw($bg);
$image->setFont('./font/arial.ttf');
$image->setTextColor(array(255, 255, 255));
$image->setStrokeWidth(1);
$image->setStrokeColor(array(0, 0, 0));
$image->rectangle(40, 40, 120, 120, array(0, 0, 0), 0.5);
$image->textBox('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', array('width' => 100, 'height' => 100, 'fontSize' => 16, 'x' => 50, 'y' => 50));
$image->rectangle(40, 190, 120, 120, array(0, 0, 0), 0.5);
$image->textBox('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam molestie tortor quam, at congue nibh imperdiet dapibus.', array('width' => 100, 'height' => 100, 'fontSize' => 16, 'x' => 50, 'y' => 200));
$image->rectangle(40, 340, 120, 120, array(0, 0, 0), 0.5);
$image->textBox('Vestibulum venenatis risus scelerisque enim faucibus, ac pretium massa condimentum. Curabitur faucibus mi at convallis viverra. Integer nec finibus ligula, id hendrerit felis.', array('width' => 100, 'height' => 100, 'fontSize' => 16, 'x' => 50, 'y' => 350));
$image->rectangle(190, 40, 320, 200, array(255, 255, 255), 0.5);
$image->setTextColor(array(0, 0, 0));
$image->setStrokeWidth(0);
$image->textBox("Auto wrap with auto font scale based on width and height of bounding box:\n\n\$image->textBox('MULTILINE TEXT', array(\n    'width' => 100,\n    'height' => 100,\n    'fontSize' => 16, // Desired starting size\n    'x' => 50,\n    'y' => 50\n));", array('width' => 300, 'height' => 180, 'fontSize' => 10, 'x' => 200, 'y' => 50));
$image->show();