当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::width方法代码示例

本文整理汇总了PHP中Image::width方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::width方法的具体用法?PHP Image::width怎么用?PHP Image::width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public static function run(\Image $res, $settings)
 {
     $resource = $res->Resource();
     $dst_w = Image::width($resource);
     $dst_h = Image::height($resource);
     $width = $settings['settings']['width'];
     $height = $settings['settings']['height'];
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $tmp = imagecreatetruecolor($dst_w, $dst_h);
     self::__fill($resource, $tmp, $settings['settings']['background']);
     imagecopyresampled($tmp, $resource, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($resource), Image::height($resource));
     if (is_resource($resource)) {
         imagedestroy($resource);
     }
     $res->setResource($tmp);
     return $res;
 }
开发者ID:symphonycms,项目名称:jit_image_manipulation,代码行数:28,代码来源:filter.resize.php

示例2: run

 public static function run($res, $width, $height, $anchor = self::TOP_LEFT, $background_fill = null)
 {
     $dst_w = Image::width($res);
     $dst_h = Image::height($res);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } else {
         if (empty($height)) {
             $ratio = $dst_h / $dst_w;
             $dst_w = $width;
             $dst_h = round($dst_w * $ratio);
         } else {
             if (empty($width)) {
                 $ratio = $dst_w / $dst_h;
                 $dst_h = $height;
                 $dst_w = round($dst_h * $ratio);
             }
         }
     }
     $tmp = imagecreatetruecolor($dst_w, $dst_h);
     self::__fill($res, $tmp, $background_fill);
     $image_width = Image::width($res);
     $image_height = Image::height($res);
     list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, $image_width, $image_height, $image_width, $image_height, $anchor);
     imagecopyresampled($tmp, $res, $src_x, $src_y, $dst_x, $dst_y, $image_width, $image_height, $image_width, $image_height);
     if (is_resource($res)) {
         imagedestroy($res);
     }
     return $tmp;
 }
开发者ID:siimsoni,项目名称:jit_image_manipulation,代码行数:31,代码来源:filter.crop.php

示例3: run

 public static function run($res, $width = NULL, $height = NULL)
 {
     $dst_w = Image::width($res);
     $dst_h = Image::height($res);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $dst = imagecreatetruecolor($dst_w, $dst_h);
     /* making the new image transparent */
     $background = imagecolorallocate($dst, 0, 0, 0);
     ImageColorTransparent($dst, $background);
     // make the new temp image all transparent
     imagealphablending($dst, false);
     imagesavealpha($dst, true);
     imageAntiAlias($dst, true);
     self::__fill($dst);
     imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
     @imagedestroy($res);
     return $dst;
 }
开发者ID:bauhouse,项目名称:sym-barebones,代码行数:29,代码来源:filter.resize.php

示例4: resize

 function resize($path, $opt)
 {
     $f3 = \Base::instance();
     $hash = $f3->hash($path . $f3->serialize($opt));
     $new_file_name = $hash . '.jpg';
     $dst_path = $f3->get('UPLOADS') . 'img/';
     $path = explode('/', $path);
     $file = array_pop($path);
     if (!is_dir($dst_path)) {
         mkdir($dst_path, 0775);
     }
     if (!file_exists($dst_path . $new_file_name)) {
         $imgObj = new \Image($file, false, implode('/', $path) . '/');
         $ow = $imgObj->width();
         $oh = $imgObj->height();
         if (!$opt['width']) {
             $opt['width'] = round($opt['height'] / $oh * $ow);
         }
         if (!$opt['height']) {
             $opt['height'] = round($opt['width'] / $ow * $oh);
         }
         $imgObj->resize((int) $opt['width'], (int) $opt['height'], $opt['crop'], $opt['enlarge']);
         $file_data = $imgObj->dump('jpeg', null, $opt['quality']);
         $f3->write($dst_path . $new_file_name, $file_data);
     }
     return $dst_path . $new_file_name;
 }
开发者ID:xfra35,项目名称:fabulog,代码行数:27,代码来源:image.php

示例5: putWatermarkInTiles

 public function putWatermarkInTiles(Image $wm, $hide = 100)
 {
     for ($y = 0; $y < $this->height(); $y += $wm->height()) {
         for ($x = 0; $x < $this->width(); $x += $wm->width()) {
             $this->putWatermark($wm, $hide, $x, $y);
         }
     }
 }
开发者ID:sd-studio,项目名称:or,代码行数:8,代码来源:image.php

示例6: run

 public static function run(\Image $res, $settings)
 {
     $src_w = $res->Meta()->width;
     $src_h = $res->Meta()->height;
     if ($settings['settings']['height'] == 0) {
         $ratio = $src_h / $src_w;
         $dst_h = round($settings['meta']['width'] * $ratio);
     } elseif ($settings['settings']['width'] == 0) {
         $ratio = $src_w / $src_h;
         $dst_w = round($settings['meta']['height'] * $ratio);
     }
     $src_r = $src_w / $src_h;
     $dst_r = $settings['meta']['width'] / $settings['meta']['height'];
     if ($src_r < $dst_r) {
         $width = $settings['meta']['width'];
         $height = null;
     } else {
         $width = null;
         $height = $settings['meta']['height'];
     }
     $resource = $res->Resource();
     $dst_w = Image::width($resource);
     $dst_h = Image::height($resource);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $image_width = Image::width($resource);
     $image_height = Image::height($resource);
     $tmp = imagecreatetruecolor($dst_w, $dst_h);
     self::__fill($resource, $tmp, $settings['settings']['background']);
     list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, $image_width, $image_height, $image_width, $image_height, $settings['settings']['position']);
     imagecopyresampled($tmp, $resource, $src_x, $src_y, $dst_x, $dst_y, $image_width, $image_height, $image_width, $image_height);
     if (is_resource($resource)) {
         imagedestroy($resource);
     }
     $res->setResource($tmp);
     return $res;
 }
开发者ID:symphonycms,项目名称:jit_image_manipulation,代码行数:47,代码来源:filter.resizeandcrop.php

示例7: saveImage

 public function saveImage()
 {
     $this->allowtypes = array('jpg', 'jpeg', 'png', 'gif');
     $this->maxsize = 1024 * 1024 * 5;
     $filename = $this->setfilename();
     $filepath = date('Y') . '/' . date('m') . '/' . $filename;
     $thumb = 'thumb/' . $filepath;
     $attachment = 'photo/' . $filepath;
     if ($this->save(C('ATTACHDIR') . $attachment)) {
         $image = new Image(C('ATTACHDIR') . $attachment);
         $image->thumb(210, 210);
         $image->save(C('ATTACHDIR') . $thumb);
         return array('name' => $filename, 'width' => $image->width(), 'height' => $image->height(), 'type' => $image->type(), 'filesize' => $this->size(), 'attachment' => $attachment, 'thumb' => $thumb);
     } else {
         return false;
     }
 }
开发者ID:xy113,项目名称:XiangBaLaoServer,代码行数:17,代码来源:class.UploadImage.php

示例8: saveChanges

 function saveChanges()
 {
     $_POST->setType('filename', 'string');
     $_POST->setType('cropimgx', 'numeric');
     $_POST->setType('cropimgy', 'numeric');
     $_POST->setType('cropimgw', 'numeric');
     $_POST->setType('cropimgh', 'numeric');
     $_REQUEST->setType('mkcopy', 'string');
     if ($_REQUEST['filename']) {
         if ($_REQUEST['mkcopy']) {
             if ($_POST['filename'] != $this->basename && $_POST['filename']) {
                 if (!file_exists($this->dirname . '/' . $_POST['filename'])) {
                     $p = $this->dirname . '/' . $_POST['filename'];
                 } else {
                     Flash::queue(__('File exists. Please give another name or delete the conflicting file. Your changes were not saved.'), 'warning');
                     break;
                 }
             } else {
                 $nrofcopies = count(glob(substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy*'));
                 if ($nrofcopies == 0) {
                     $nrofcopies = '';
                 }
                 $p = substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy' . ($nrofcopies + 1) . substr($this->path, -(strlen($this->extension) + 1));
             }
             touch($p);
             $copy = File::open($p);
         } else {
             if ($_POST['filename'] != $this->basename) {
                 $this->rename($_POST['filename']);
             }
             $p = $this->path;
             $img = new Image($this->path);
             if ($_POST['cropimgw'] && $_POST['cropimgh']) {
                 $width = $img->width();
                 $s = $width / min($width, 400);
                 $img->crop(round($s * $_POST['cropimgx']), round($s * $_POST['cropimgy']), round($s * $_POST['cropimgw']), round($s * $_POST['cropimgh']));
             }
             if ($_REQUEST['imgrot']) {
                 $img->rotate($_REQUEST['imgrot']);
             }
             $img->save($p);
             Flash::queue(__('Your changes were saved'));
         }
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:45,代码来源:ImageEditor.php

示例9: correct

 function correct($path)
 {
     // Уменьшаем до максимально допустимых размеров
     //var_dump($path);
     $img = new \Image($path);
     $img->resize(1500, 1500, false, false);
     if ($this->fw->get('site.use_watermark')) {
         $overlay = new \Image('../' . APP_FOLDER . '/views/' . $this->fw->get('site.tpl') . '/watermark.png');
         $overlay->resize(1500, 1500, true, false);
         $img->overlay($overlay, (int) $this->fw->get('site.watermark.x') | (int) $this->fw->get('site.watermark.y'));
     } elseif ($this->fw->get('site.use_text_watermark')) {
         // Создаём изображение-оверлей с надписью
         $wm = $this->createTextWatermark($img->width(), $img->height());
         $overlay = new \Image($wm);
         // 2 добавить его к текущему изборажению
         $img->overlay($overlay, \Image::POS_Center | \Image::POS_Middle);
     }
     $this->fw->write($path, $img->dump());
 }
开发者ID:k-kalashnikov,项目名称:forKoda,代码行数:19,代码来源:ImageCorrector.php

示例10: run

 public static function run($res, $width, $height, $anchor = self::TOP_LEFT, $background_fill = 'fff')
 {
     $dst_w = Image::width($res);
     $dst_h = Image::height($res);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $tmp = imagecreatetruecolor($dst_w, $dst_h);
     self::__fill($tmp, $background_fill);
     list($src_x, $src_y, $dst_x, $dst_y) = self::__calculateDestSrcXY($dst_w, $dst_h, Image::width($res), Image::height($res), Image::width($res), Image::height($res), $anchor);
     imagecopyresampled($tmp, $res, $src_x, $src_y, $dst_x, $dst_y, Image::width($res), Image::height($res), Image::width($res), Image::height($res));
     @imagedestroy($res);
     return $tmp;
     //			self::__copy($tmp, $res, true);
 }
开发者ID:pointybeard,项目名称:jit_image_manipulation,代码行数:24,代码来源:filter.crop.php

示例11: run

 public static function run($res, $width = NULL, $height = NULL)
 {
     $dst_w = Image::width($res);
     $dst_h = Image::height($res);
     if (!empty($width) && !empty($height)) {
         $dst_w = $width;
         $dst_h = $height;
     } elseif (empty($height)) {
         $ratio = $dst_h / $dst_w;
         $dst_w = $width;
         $dst_h = round($dst_w * $ratio);
     } elseif (empty($width)) {
         $ratio = $dst_w / $dst_h;
         $dst_h = $height;
         $dst_w = round($dst_h * $ratio);
     }
     $dst = imagecreatetruecolor($dst_w, $dst_h);
     //imagealphablending( $dst, false );
     //imagesavealpha( $dst, true );
     self::__fill($dst);
     imagecopyresampled($dst, $res, 0, 0, 0, 0, $dst_w, $dst_h, Image::width($res), Image::height($res));
     @imagedestroy($res);
     return $dst;
 }
开发者ID:bauhouse,项目名称:sym-fluid960gs,代码行数:24,代码来源:filter.resize.php

示例12: image_special

 public function image_special($APP)
 {
     $FILE = $APP->get('POST.f');
     $PREVIEW = $APP->get('POST.p');
     $SPECIALE = $APP->get('POST.e');
     $HEIGHT = $APP->get('POST.h');
     $WIDTH = $APP->get('POST.w');
     $PATH_PARTS = pathinfo($APP->get('UPLOADS') . $FILE);
     $APP->set('FILE_EXTENSION', strtolower($PATH_PARTS['extension']));
     $APP->set('FILE_FILENAME', $PATH_PARTS['filename']);
     $PROCESS_FILTER = '';
     if ($APP->get('FILE_EXTENSION') == 'jpg') {
         $PROCESS_FILTER = 'jpeg';
     } else {
         if ($APP->get('FILE_EXTENSION') == 'gif') {
             $PROCESS_FILTER = 'gif';
         } else {
             if ($APP->get('FILE_EXTENSION') == 'png') {
                 $PROCESS_FILTER = 'png';
             } else {
                 if ($APP->get('FILE_EXTENSION') == 'wbmp') {
                     $PROCESS_FILTER = 'wbmp';
                 }
             }
         }
     }
     if ($APP->get('FILE_EXTENSION') == 'png' || $APP->get('FILE_EXTENSION') == 'jpg' || $APP->get('FILE_EXTENSION') == 'jpeg' || $APP->get('FILE_EXTENSION') == 'gif' || $APP->get('FILE_EXTENSION') == 'wbmp') {
         $img = new Image($FILE, false, $APP->get('UPLOADS'));
         $IMAGE_WIDTH = 0;
         $IMAGE_HEIGHT = 0;
         $IMAGE_WIDTH = $img->width();
         $IMAGE_HEIGHT = $img->height();
         if ($HEIGHT && $WIDTH && $HEIGHT != $IMAGE_HEIGHT && $WIDTH != $IMAGE_WIDTH) {
             $img->resize($WIDTH, $HEIGHT, false, false);
         }
         switch ($SPECIALE) {
             case 'invert':
                 $img->invert();
                 break;
             case 'grayscale':
                 $img->grayscale();
                 break;
             case 'emboss':
                 $img->emboss();
                 break;
             case 'sepia':
                 $img->sepia();
                 break;
             case 'pixelate':
                 $img->pixelate(10);
                 break;
             case 'rotate90':
                 $img->rotate(-90);
                 break;
             case 'rotate180':
                 $img->rotate(-180);
                 break;
             case 'rotate270':
                 $img->rotate(-270);
                 break;
             case 'hflip':
                 $img->hflip();
                 break;
             case 'vflip':
                 $img->vflip();
                 break;
             case 'origin':
                 echo $APP->get('CONSTRUCTR_BASE_URL') . '/UPLOADS/' . $FILE;
                 die;
                 break;
         }
         $img->save();
         $TS = time();
         @file_put_contents($APP->get('UPLOADS') . 'TMP/' . $TS . '.png', $img->dump($PROCESS_FILTER));
         echo $APP->get('CONSTRUCTR_BASE_URL') . '/UPLOADS/TMP/' . $TS . '.png';
     }
 }
开发者ID:phaziz,项目名称:ConstructrCMS-3,代码行数:77,代码来源:ConstructrUploads.php

示例13: exit

    //Upload de la photo selectionnée
    if ($_FILES['photo_' . $group['id']]['tmp_name'] != null) {
        $photos_dir = '../images/groupes/';
        $tmp_file = $_FILES['photo_' . $group['id']]['tmp_name'];
        if (!is_uploaded_file($tmp_file)) {
            exit("Le fichier uploadé est introuvalbe");
        }
        //Vérification extension
        $type_file = $_FILES['photo_' . $group['id']]['type'];
        if (!strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg') && !strstr($type_file, 'bmp') && !strstr($type_file, 'gif') && !strstr($type_file, 'png')) {
            exit("Le fichier n'est pas une image");
        }
        //copie dans le dossier de destination
        $name_file = 'photo_' . $group['id'] . '.jpg';
        if (preg_match('#[\\x00-\\x1F\\x7F-\\x9F/\\\\]#', $name_file)) {
            exit("Nom de fichier non valide");
        } else {
            if (!move_uploaded_file($tmp_file, $photos_dir . $name_file)) {
                exit("Impossible de coier le fichier dans {$photos_dir}");
            }
        }
        $thumb = new Image($photos_dir . $name_file);
        $thumb->height(200);
        $thumb->width(268);
        $thumb->save();
        // => fichier uploadé
    }
    mysql_query("UPDATE groups SET\tname='" . $_POST['name_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnbr='" . $_POST['nbr_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thorraire='" . $_POST['horraire_' . $group['id']] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tage='" . $_POST['age_' . $group['id']] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE id='" . $group['id'] . "'") or die(mysql_error());
    header('Location: ../index.php?p=groupes');
}
mysql_close($connexion);
开发者ID:shlag,项目名称:FSG2010,代码行数:31,代码来源:edit_groups.php

示例14: dirname

define('CARD_DIR', dirname(__FILE__) . '/card');
define('SOURCE_DIR', dirname(__FILE__) . '/source');
define('SPOIL_CARD', '_');
define('WIDTH', 140);
define('HEIGHT', 105);
$cutRange = [[248, 270], [248, 540], [248, 810], [248, 1080], [1323, 270], [1323, 540], [1323, 810], [1323, 1080]];
$images = ['img51.jpg', 'img54.jpg', 'img57.jpg', 'img60.jpg', 'img63.jpg'];
$cardnum = [0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14, 16, 19, 17, 18, 20, 22, 23, 24, 25, 26, 28, 29, 27, 31, 33, 35, 36, 21, 32, 30, 34, 0, 0];
$count = 0;
foreach ($images as $imgname) {
    foreach ($cutRange as $r) {
        list($x, $y) = $r;
        $thumb = new Image(SOURCE_DIR . '/' . $imgname);
        $thumb->width(WIDTH);
        $thumb->height(HEIGHT);
        $thumb->crop($x, $y);
        $thumb->dir(CARD_DIR);
        $name = $cardnum[$count++];
        $thumb->name($name == 0 ? SPOIL_CARD : $name);
        $thumb->save();
    }
}
// 消費財
$thumb = new Image(SOURCE_DIR . '/' . 'img63.jpg');
$thumb->width(WIDTH);
$thumb->height(HEIGHT);
$thumb->crop(1323, 1110);
$thumb->dir(CARD_DIR);
$thumb->name('99');
$thumb->save();
unlink(CARD_DIR . '/' . SPOIL_CARD . '.jpg');
开发者ID:sopra,项目名称:NationalEconomySolo,代码行数:31,代码来源:cutter.php

示例15: getThumb

 /**
  * Creates a thumbnail of the image
  * @param string $file name of the file
  * @return string
  */
 function getThumb($file)
 {
     $image = new Image($this->getPathLocal($file));
     if (!in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), array('png', 'gif', 'jpg', 'jpeg'))) {
         $file .= '.jpg';
     }
     /* disabled because of problems with the safe emailer preg_replace queries
        if($image->thumbnail() !== false) {
            return $image->thumbnail($this->thumbMaxSize,$this->thumbMaxSize);
        } else {*/
     if (!file_exists($this->getThumbPathLocal($file))) {
         $w = $image->width();
         $h = $image->height();
         if ($w >= $h) {
             $image->resize($this->thumbMaxSize);
         } else {
             $image->resize(false, $this->thumbMaxSize);
         }
         if (!is_dir($this->getThumbPathLocal(''))) {
             mkdir($this->getThumbPathLocal(''), 0755, true);
         }
         $image->save($this->getThumbPathLocal($file));
     }
     $fname = htmlentities(utf8($file));
     return '<img src="' . $this->galleryDirPublic . str_replace('%2F', '/', rawurlencode($this->thumbDirPublic . $this->ualbumName . ($this->ualbumName ? '/' : '') . $fname)) . '" alt="' . $fname . '" />';
     //}
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:32,代码来源:Gallery.php


注:本文中的Image::width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。