• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imageDestroy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imageDestroy函数的典型用法代码示例。如果您正苦于以下问题:PHP imageDestroy函数的具体用法?PHP imageDestroy怎么用?PHP imageDestroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: execute

 /**
  * Method to apply a background color to an image resource.
  *
  * @param   array  $options  An array of options for the filter.
  *                           color  Background matte color
  *
  * @return  void
  *
  * @since   3.4
  * @throws  InvalidArgumentException
  * @deprecated  5.0  Use Joomla\Image\Filter\Backgroundfill::execute() instead
  */
 public function execute(array $options = array())
 {
     // Validate that the color value exists and is an integer.
     if (!isset($options['color'])) {
         throw new InvalidArgumentException('No color value was given. Expected string or array.');
     }
     $colorCode = !empty($options['color']) ? $options['color'] : null;
     // Get resource dimensions
     $width = imagesX($this->handle);
     $height = imagesY($this->handle);
     // Sanitize color
     $rgba = $this->sanitizeColor($colorCode);
     // Enforce alpha on source image
     if (imageIsTrueColor($this->handle)) {
         imageAlphaBlending($this->handle, false);
         imageSaveAlpha($this->handle, true);
     }
     // Create background
     $bg = imageCreateTruecolor($width, $height);
     imageSaveAlpha($bg, empty($rgba['alpha']));
     // Allocate background color.
     $color = imageColorAllocateAlpha($bg, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
     // Fill background
     imageFill($bg, 0, 0, $color);
     // Apply image over background
     imageCopy($bg, $this->handle, 0, 0, 0, 0, $width, $height);
     // Move flattened result onto curent handle.
     // If handle was palette-based, it'll stay like that.
     imageCopy($this->handle, $bg, 0, 0, 0, 0, $width, $height);
     // Free up memory
     imageDestroy($bg);
     return;
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:45,代码来源:backgroundfill.php


示例2: createImage

 public function createImage($text = '', $fontSize = 5)
 {
     // GD's built-in fonts are numbered from 1 - 5
     $font_size = $fontSize;
     // Calculate the appropriate image size
     $image_height = intval(imageFontHeight($font_size) * 2);
     $image_width = intval(strlen($text) * imageFontWidth($font_size) * 1.3);
     // Create the image
     $image = imageCreate($image_width, $image_height);
     // Create the colors to use in the image
     // gray background
     $back_color = imageColorAllocate($image, 216, 216, 216);
     // blue text
     $text_color = imageColorAllocate($image, 0, 0, 255);
     // black border
     $rect_color = imageColorAllocate($image, 0, 0, 0);
     // Figure out where to draw the text
     // (Centered horizontally and vertically
     $x = ($image_width - imageFontWidth($font_size) * strlen($text)) / 2;
     $y = ($image_height - imageFontHeight($font_size)) / 2;
     // Draw the text
     imageString($image, $font_size, $x, $y, $text, $text_color);
     // Draw a black border
     imageRectangle($image, 0, 0, imageSX($image) - 1, imageSY($image) - 1, $rect_color);
     // Send the image to the browser
     header('Content-Type: image/png');
     imagePNG($image);
     imageDestroy($image);
 }
开发者ID:puncoz,项目名称:presentation,代码行数:29,代码来源:images.php


示例3: resize_image

 public function resize_image($data, $imgX, $sizedef, $lid, $imgid)
 {
     $file = $data["raw_name"];
     $type = $data["file_ext"];
     $outfile = $imgX[$sizedef]['dir'] . "/" . $lid . "/" . $file . '.jpg';
     $path = $this->config->item("upload_dir");
     $image = $this->create_image_container($file, $type);
     if ($image) {
         $size = GetImageSize($path . $file . $type);
         $old = $image;
         // сей форк - не просто так. непонятно, правда, почему...
         if ($size['1'] < $size['0']) {
             $h_new = round($imgX[$sizedef]['max_dim'] * ($size['1'] / $size['0']));
             $measures = array($imgX[$sizedef]['max_dim'], $h_new);
         }
         if ($size['1'] >= $size['0']) {
             $h_new = round($imgX[$sizedef]['max_dim'] * ($size['0'] / $size['1']));
             $measures = array($h_new, $imgX[$sizedef]['max_dim']);
         }
         $new = ImageCreateTrueColor($measures[0], $measures[1]);
         ImageCopyResampled($new, $image, 0, 0, 0, 0, $measures[0], $measures[1], $size['0'], $size['1']);
         imageJpeg($new, $outfile, $imgX[$sizedef]['quality']);
         $this->db->query("UPDATE `images` SET `images`.`" . $sizedef . "` = ? WHERE `images`.`id` = ?", array(implode($measures, ","), $imgid));
         imageDestroy($new);
     }
 }
开发者ID:korzhevdp,项目名称:MiniGIS,代码行数:26,代码来源:uploadmodel.php


示例4: add

 static function add($file, $wpath)
 {
     if (file_exists($file)) {
         $new_h = 1200;
         // new height for resize image
         $new_w = 1200;
         // new width for resize image
         $image = imagecreatefromjpeg($file);
         // Load the logo image
         $logoImage = imagecreatefrompng(self::getWebDir() . self::WATERMARK);
         // Get dimensions
         $imageWidth = imagesx($image);
         $imageHeight = imagesy($image);
         $logoWidth = imagesx($logoImage);
         $logoHeight = imagesy($logoImage);
         // Paste the lo$filego
         imagecopy($image, $logoImage, ($imageWidth - $logoWidth) / 2, ($imageHeight - $logoHeight) / 2, 0, 0, $logoWidth, $logoHeight);
         // Paste the logo
         $new_image = imagecreatetruecolor($new_w, $new_h);
         imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_w, $new_h, $imageWidth, $imageHeight);
         $mime = self::getMimeType($file);
         $name = self::getName($file);
         if ($mime == 'image/png') {
             imagejpeg($new_image, $wpath, 100);
         } elseif ($mime == 'image/jpeg') {
             imagejpeg($new_image, $wpath, 100);
         } elseif ($mime == 'image/gif') {
             imagejpeg($new_image, $wpath, 100);
         }
         // Release memory
         imageDestroy($image);
         imageDestroy($new_image);
         imageDestroy($logoImage);
     }
 }
开发者ID:kirians,项目名称:sf,代码行数:35,代码来源:watermark.class.php


示例5: resizeImage

 private function resizeImage($file, $data, $tmd = 600, $quality = 100)
 {
     $data['type'] = "image/jpeg";
     $basename = basename($file);
     $filesDir = $this->input->post('uploadDir');
     // хэш нередактируемой карты!
     $uploaddir = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', $tmd, $filesDir), DIRECTORY_SEPARATOR);
     $srcFile = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', 'source', $filesDir, $basename), DIRECTORY_SEPARATOR);
     $image = $this->createimageByType($data, $srcFile);
     if (!file_exists($uploaddir)) {
         mkdir($uploaddir, 0775, true);
     }
     $size = GetImageSize($srcFile);
     $new = ImageCreateTrueColor($size['1'], $size['0']);
     if ($size['1'] > $tmd || $size['0'] > $tmd) {
         if ($size['1'] < $size['0']) {
             $hNew = round($tmd * $size['1'] / $size['0']);
             $new = ImageCreateTrueColor($tmd, $hNew);
             ImageCopyResampled($new, $image, 0, 0, 0, 0, $tmd, $hNew, $size['0'], $size['1']);
         }
         if ($size['1'] >= $size['0']) {
             $hNew = round($tmd * $size['0'] / $size['1']);
             $new = ImageCreateTrueColor($hNew, $tmd);
             ImageCopyResampled($new, $image, 0, 0, 0, 0, $hNew, $tmd, $size['0'], $size['1']);
         }
     }
     //print $uploaddir."/".TMD."/".$filename.".jpg<br>";
     imageJpeg($new, $uploaddir . DIRECTORY_SEPARATOR . $basename, $quality);
     //header("content-type: image/jpeg");// активировать для отладки
     //imageJpeg ($new, "", 100);//активировать для отладки
     imageDestroy($new);
 }
开发者ID:korzhevdp,项目名称:freehand,代码行数:32,代码来源:upload.php


示例6: king_def

function king_def()
{
    global $king;
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // 过去的时间
    header("Content-type: image/png");
    $salt = kc_get('salt', 1, 1);
    $width = $king->config('verifywidth');
    //图片长度
    $height = $king->config('verifyheight');
    //图片高度
    $size = $king->config('verifysize');
    //文字大小
    $num = $king->config('verifynum');
    //文字数量
    $content = $king->config('verifycontent');
    //随机字符
    $array_content = explode('|', $content);
    $array_content = array_diff($array_content, array(null));
    $array_font = kc_f_getdir('system/verify_font', 'ttf|ttc');
    $str = '';
    $img = imageCreate($width, $height);
    //创建一个空白图像
    imageFilledRectangle($img, 0, 0, $width, $height, imagecolorallocate($img, 255, 255, 255));
    //写字
    for ($i = 0; $i < $num; $i++) {
        $code = $array_content[array_rand($array_content)];
        $str .= $code;
        //验证码字符
        $color = imageColorAllocate($img, rand(0, 128), rand(0, 128), rand(0, 128));
        $font = 'verify_font/' . $array_font[array_rand($array_font)];
        //随机读取一个字体
        $left = rand(round($size * 0.2), round($size * 0.4)) + $i * $size;
        imagettftext($img, rand(round($size * 0.7), $size), rand(-20, 20), $left, rand(round($size * 1.2), $size * 1.4), $color, $font, $code);
    }
    //画星号
    $max = $width * $height / 400;
    for ($i = 0; $i < $max; $i++) {
        imagestring($img, 15, rand(0, $width), rand(0, $height), '*', rand(192, 250));
    }
    //画点
    $max = $width * $height / 40;
    for ($i = 0; $i < $max; $i++) {
        imageSetPixel($img, rand(0, $width), rand(0, $height), rand(1, 200));
    }
    //画线
    $max = $width * $height / 800;
    for ($i = 0; $i < $max; $i++) {
        imageline($img, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), rand(0, 255));
    }
    //写验证码到verify中
    $verify = new KC_Verify_class();
    $verify->Put($salt, $str);
    imagePng($img);
    imageDestroy($img);
    $verify->Clear();
}
开发者ID:jonycookie,项目名称:projectm2,代码行数:59,代码来源:verify.php


示例7: __destruct

 public function __destruct()
 {
     if ($this->avatar) {
         imageDestroy($this->avatar);
     }
     if ($this->overlay) {
         imageDestroy($this->overlay);
     }
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:9,代码来源:instantavatar.php


示例8: create_thumb

function create_thumb($path, $thumb_path, $width = THUMB_WIDTH, $height = THUMB_HEIGHT)
{
    $image_info = getImageSize($path);
    // see EXIF for faster way
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                // not the same as IMAGETYPE
                $o_im = @imageCreateFromGIF($path);
            } else {
                throw new Exception('GIF images are not supported');
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $o_im = @imageCreateFromJPEG($path);
            } else {
                throw new Exception('JPEG images are not supported');
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $o_im = @imageCreateFromPNG($path);
            } else {
                throw new Exception('PNG images are not supported');
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $o_im = @imageCreateFromWBMP($path);
            } else {
                throw new Exception('WBMP images are not supported');
            }
            break;
        default:
            throw new Exception($image_info['mime'] . ' images are not supported');
            break;
    }
    list($o_wd, $o_ht, $html_dimension_string) = $image_info;
    $ratio = $o_wd / $o_ht;
    $t_ht = $width;
    $t_wd = $height;
    if (1 > $ratio) {
        $t_wd = round($o_wd * $t_wd / $o_ht);
    } else {
        $t_ht = round($o_ht * $t_ht / $o_wd);
    }
    $t_wd = $t_wd < 1 ? 1 : $t_wd;
    $t_ht = $t_ht < 1 ? 1 : $t_ht;
    $t_im = imageCreateTrueColor($t_wd, $t_ht);
    imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
    imagejpeg($t_im, $thumb_path, 85);
    chmod($thumb_path, 0664);
    imageDestroy($o_im);
    imageDestroy($t_im);
    return array($t_wd, $t_ht);
}
开发者ID:sztanpet,项目名称:aoiboard,代码行数:57,代码来源:functions.php


示例9: __destruct

 /**
  * Free the memory of the image
  * @return null
  */
 public function __destruct()
 {
     if (!$this->resource) {
         return;
     }
     try {
         imageDestroy($this->resource);
     } catch (Exception $exception) {
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:14,代码来源:Image.php


示例10: draw

 /**
  * Draws the pie chart, with optional supersampled anti-aliasing.
  * @param int $aa
  */
 public function draw($aa = 4)
 {
     $this->canvas = imageCreateTrueColor($this->width, $this->height);
     // Set anti-aliasing for the pie chart.
     imageAntiAlias($this->canvas, true);
     imageFilledRectangle($this->canvas, 0, 0, $this->width, $this->height, $this->_convertColor($this->backgroundColor));
     $total = 0;
     $sliceStart = -90;
     // Start at 12 o'clock.
     $titleHeight = $this->_drawTitle();
     $legendWidth = $this->_drawLegend($titleHeight);
     // Account for the space occupied by the legend and its padding.
     $pieCentreX = ($this->width - $legendWidth) / 2;
     // Account for the space occupied by the title.
     $pieCentreY = $titleHeight + ($this->height - $titleHeight) / 2;
     // 10% padding on the top and bottom of the pie.
     $pieDiameter = round(min($this->width - $legendWidth, $this->height - $titleHeight) * 0.85);
     foreach ($this->slices as $slice) {
         $total += $slice['value'];
     }
     // If anti-aliasing is enabled, we supersample the pie to work around
     // the fact that GD does not provide anti-aliasing natively.
     if ($aa > 0) {
         $ssDiameter = $pieDiameter * $aa;
         $ssCentreX = $ssCentreY = $ssDiameter / 2;
         $superSample = imageCreateTrueColor($ssDiameter, $ssDiameter);
         imageFilledRectangle($superSample, 0, 0, $ssDiameter, $ssDiameter, $this->_convertColor($this->backgroundColor));
         foreach ($this->slices as $slice) {
             $sliceWidth = 360 * $slice['value'] / $total;
             // Skip slices that are too small to draw / be visible.
             if ($sliceWidth == 0) {
                 continue;
             }
             $sliceEnd = $sliceStart + $sliceWidth;
             imageFilledArc($superSample, $ssCentreX, $ssCentreY, $ssDiameter, $ssDiameter, $sliceStart, $sliceEnd, $this->_convertColor($slice['color']), IMG_ARC_PIE);
             // Move along to the next slice.
             $sliceStart = $sliceEnd;
         }
         imageCopyResampled($this->canvas, $superSample, $pieCentreX - $pieDiameter / 2, $pieCentreY - $pieDiameter / 2, 0, 0, $pieDiameter, $pieDiameter, $ssDiameter, $ssDiameter);
         imageDestroy($superSample);
     } else {
         // Draw the slices.
         foreach ($this->slices as $slice) {
             $sliceWidth = 360 * $slice['value'] / $total;
             // Skip slices that are too small to draw / be visible.
             if ($sliceWidth == 0) {
                 continue;
             }
             $sliceEnd = $sliceStart + $sliceWidth;
             imageFilledArc($this->canvas, $pieCentreX, $pieCentreY, $pieDiameter, $pieDiameter, $sliceStart, $sliceEnd, $this->_convertColor($slice['color']), IMG_ARC_PIE);
             // Move along to the next slice.
             $sliceStart = $sliceEnd;
         }
     }
 }
开发者ID:samchristy,项目名称:piechart,代码行数:59,代码来源:PieChartGD.php


示例11: placeholder

 /**
  * Placeholder code adapted from dummyimage.com
  */
 public static function placeholder($width, $height)
 {
     $file_format = 'gif';
     $width = $width;
     $height = $height;
     $text_angle = 0;
     $font = Load::getModulePath('media') . 'assets/mplus-1c-medium.ttf';
     $img = imageCreate($width, $height);
     $bg_color = imageColorAllocate($img, 196, 196, 196);
     $fg_color = imageColorAllocate($img, 94, 94, 94);
     $lines = 1;
     $text = $width . 'x' . $height;
     $fontsize = max(min($width / strlen($text) * 1.15, $height * 0.5), 5);
     $textBox = self::_imagettfbbox_t($fontsize, $text_angle, $font, $text);
     $textWidth = ceil(($textBox[4] - $textBox[1]) * 1.07);
     $textHeight = ceil((abs($textBox[7]) + abs($textBox[1])) * 1);
     $textX = ceil(($width - $textWidth) / 2);
     $textY = ceil(($height - $textHeight) / 2 + $textHeight);
     imageFilledRectangle($img, 0, 0, $width, $height, $bg_color);
     imagettftext($img, $fontsize, $text_angle, $textX, $textY, $fg_color, $font, $text);
     $offset = 60 * 60 * 24 * 14;
     //14 Days
     $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
     header($ExpStr);
     //Set a far future expire date. This keeps the image locally cached by the user for less hits to the server.
     header('Cache-Control:	max-age=120');
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() - $offset) . " GMT");
     header('Content-type: image/' . $file_format);
     //Set the header so the browser can interpret it as an image and not a bunch of weird text.
     switch ($file_format) {
         case 'gif':
             imagegif($img);
             break;
         case 'png':
             imagepng($img);
             break;
         case 'jpg':
             imagejpeg($img);
             break;
         case 'jpeg':
             imagejpeg($img);
             break;
     }
     imageDestroy($img);
     exit;
 }
开发者ID:simudream,项目名称:caffeine,代码行数:49,代码来源:image.php


示例12: AnimatedOut

 function AnimatedOut()
 {
     for ($i = 0; $i < ANIM_FRAMES; $i++) {
         $image = imageCreateTrueColor(imageSX($this->image), imageSY($this->image));
         if (imageCopy($image, $this->image, 0, 0, 0, 0, imageSX($this->image), imageSY($this->image))) {
             Captcha::DoNoise($image, 200, 0);
             Ob_Start();
             imageGif($image);
             imageDestroy($image);
             $f_arr[] = Ob_Get_Contents();
             $d_arr[] = ANIM_DELAYS;
             Ob_End_Clean();
         }
     }
     $GIF = new GIFEncoder($f_arr, $d_arr, 0, 2, -1, -1, -1, 'C_MEMORY');
     return $GIF->GetAnimation();
 }
开发者ID:joly,项目名称:web2project,代码行数:17,代码来源:Captcha.class.php


示例13: save

 function save($save = "", $gd_version)
 {
     if ($gd_version == 2) {
         $this->img["des"] = imagecreatetruecolor($this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
         @imagecopyresampled($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
     }
     if ($gd_version == 1) {
         $this->img["des"] = imagecreate($this->img["lebar_thumb"], $this->img["tinggi_thumb"]);
         @imagecopyresized($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
     }
     if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
         //JPEG
         imageJPEG($this->img["des"], "{$save}", $this->img["quality"]);
     } elseif ($this->img["format"] == "PNG") {
         //PNG
         imagePNG($this->img["des"], "{$save}");
     }
     // Memory cleanup
     @imageDestroy($this->img["des"]);
 }
开发者ID:hyrmedia,项目名称:modules,代码行数:20,代码来源:class.thumbnail.inc.php


示例14: createTestImage

 /**
  * Create test image.
  *
  * @param string $filename
  * @return void
  */
 protected function createTestImage($filename)
 {
     $filename = $this->getFullPath($filename);
     if (!file_exists($filename)) {
         // Create an image with the specified dimensions
         $image = imageCreate(300, 200);
         // Create a color (this first call to imageColorAllocate
         //  also automatically sets the image background color)
         $colorYellow = imageColorAllocate($image, 255, 255, 0);
         // Draw a rectangle
         imageFilledRectangle($image, 50, 50, 250, 150, $colorYellow);
         $directory = dirname($filename);
         if (!file_exists($directory)) {
             mkdir($directory, 0777, true);
         }
         imageJpeg($image, $filename);
         // Release memory
         imageDestroy($image);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:MediaGallery.php


示例15: resize_bg

 public static function resize_bg($image, $model, $id, $width, $height)
 {
     $startImage = $image;
     $test_name = 'test-' . $width . '-' . $height . '-' . time() . '.jpg';
     if (!$image) {
         return '/images/blank.png';
     }
     $directory = self::checkAndCreateDirectory($model, $id, self::RESIZE_BG_PATH, $width, $height);
     $imageParts = explode('/', $image);
     $imageName = end($imageParts);
     try {
         $image_factory = Image::factory(PUBLIC_ROOT . 'files/' . $model . '/' . $id . '/' . $imageName);
     } catch (Exception $e) {
         return $startImage;
     }
     try {
         if (!file_exists($directory . $imageName)) {
             $img = imagecreate($width, $height);
             $white = ImageColorAllocate($img, 255, 255, 255);
             ImageFill($img, 0, 0, $white);
             header('Content-Type: image/jpg;');
             $test_file = APPPATH . 'cache/' . $test_name;
             imageJPEG($img, $test_file);
             $image = Image::factory($test_file);
             $image->watermark($image_factory->resize(intval($width), intval($height), Kohana_Image::AUTO))->save($directory . $imageName, 99);
             imageDestroy($img);
             @unlink($test_file);
         }
     } catch (Exception $e) {
         return $startImage;
     }
     $path = '/files/' . self::RESIZE_BG_PATH . '/' . $width;
     if ($height) {
         $path .= 'x' . $height;
     }
     if (file_exists($directory . $imageName)) {
         return $path . '/' . $model . '/' . $id . '/' . $imageName;
     }
     return $startImage;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:40,代码来源:Image.php


示例16: resizeImage

function resizeImage($file, $max_x, $max_y, $forcePng = false)
{
    if ($max_x <= 0 || $max_y <= 0) {
        $max_x = 5;
        $max_y = 5;
    }
    $src = BASEDIR . '/avatars/' . $file;
    list($width, $height, $type) = getImageSize($src);
    $scale = min($max_x / $width, $max_y / $height);
    $newWidth = $width * $scale;
    $newHeight = $height * $scale;
    $img = imagecreatefromstring(file_get_contents($src));
    $black = imagecolorallocate($img, 0, 0, 0);
    $resizedImage = imageCreateTrueColor($newWidth, $newHeight);
    imagecolortransparent($resizedImage, $black);
    imageCopyResampled($resizedImage, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
    imageDestroy($img);
    unlink($src);
    if (!$forcePng) {
        switch ($type) {
            case IMAGETYPE_JPEG:
                imageJpeg($resizedImage, BASEDIR . '/avatars/' . $file);
                break;
            case IMAGETYPE_GIF:
                imageGif($resizedImage, BASEDIR . '/avatars/' . $file);
                break;
            case IMAGETYPE_PNG:
                imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
                break;
            default:
                imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
                break;
        }
    } else {
        imagePng($resizedImage, BASEDIR . '/avatars/' . $file . '.png');
    }
    return;
}
开发者ID:kandran,项目名称:flyspray,代码行数:38,代码来源:modify.inc.php


示例17: createThumb


//.........这里部分代码省略.........
     }
     $iFinalWidth = $maxWidth == 0 ? $sourceImageWidth : $maxWidth;
     $iFinalHeight = $maxHeight == 0 ? $sourceImageHeight : $maxHeight;
     if ($sourceImageWidth <= $iFinalWidth && $sourceImageHeight <= $iFinalHeight) {
         if ($sourceFile != $targetFile) {
             copy($sourceFile, $targetFile);
         }
         return true;
     }
     if ($preserverAspectRatio) {
         // Gets the best size for aspect ratio resampling
         $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight);
     } else {
         $oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
     }
     CKFinder_Connector_Utils_Misc::setMemoryForImage($sourceImageWidth, $sourceImageHeight, $sourceImageBits, $sourceImageChannels);
     switch ($sourceImageAttr['mime']) {
         case 'image/gif':
             if (@imagetypes() & IMG_GIF) {
                 $oImage = @imagecreatefromgif($sourceFile);
             } else {
                 $ermsg = 'GIF images are not supported';
             }
             break;
         case 'image/jpeg':
             if (@imagetypes() & IMG_JPG) {
                 $oImage = @imagecreatefromjpeg($sourceFile);
             } else {
                 $ermsg = 'JPEG images are not supported';
             }
             break;
         case 'image/png':
             if (@imagetypes() & IMG_PNG) {
                 $oImage = @imagecreatefrompng($sourceFile);
             } else {
                 $ermsg = 'PNG images are not supported';
             }
             break;
         case 'image/wbmp':
             if (@imagetypes() & IMG_WBMP) {
                 $oImage = @imagecreatefromwbmp($sourceFile);
             } else {
                 $ermsg = 'WBMP images are not supported';
             }
             break;
         case 'image/bmp':
             /*
              * This is sad that PHP doesn't support bitmaps.
              * Anyway, we will use our custom function at least to display thumbnails.
              * We'll not resize images this way (if $sourceFile === $targetFile),
              * because user defined imagecreatefrombmp and imagecreatebmp are horribly slow
              */
             if ($bmpSupported && @imagetypes() & IMG_JPG && $sourceFile != $targetFile) {
                 $oImage = CKFinder_Connector_Utils_Misc::imageCreateFromBmp($sourceFile);
             } else {
                 $ermsg = 'BMP/JPG images are not supported';
             }
             break;
         default:
             $ermsg = $sourceImageAttr['mime'] . ' images are not supported';
             break;
     }
     if (isset($ermsg) || false === $oImage) {
         return false;
     }
     $oThumbImage = imagecreatetruecolor($oSize["Width"], $oSize["Height"]);
     if ($sourceImageAttr['mime'] == 'image/png') {
         $bg = imagecolorallocatealpha($oThumbImage, 255, 255, 255, 127);
         // (PHP 4 >= 4.3.2, PHP 5)
         imagefill($oThumbImage, 0, 0, $bg);
         imagealphablending($oThumbImage, false);
         imagesavealpha($oThumbImage, true);
     }
     //imagecopyresampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight);
     CKFinder_Connector_Utils_Misc::fastImageCopyResampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight, (int) max(floor($quality / 20), 6));
     switch ($sourceImageAttr['mime']) {
         case 'image/gif':
             imagegif($oThumbImage, $targetFile);
             break;
         case 'image/jpeg':
         case 'image/bmp':
             imagejpeg($oThumbImage, $targetFile, $quality);
             break;
         case 'image/png':
             imagepng($oThumbImage, $targetFile);
             break;
         case 'image/wbmp':
             imagewbmp($oThumbImage, $targetFile);
             break;
     }
     $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
     if (file_exists($targetFile) && ($perms = $_config->getChmodFiles())) {
         $oldUmask = umask(0);
         chmod($targetFile, $perms);
         umask($oldUmask);
     }
     imageDestroy($oImage);
     imageDestroy($oThumbImage);
     return true;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:Thumbnail.php


示例18: imgRotate

 /**
  * Rotate image
  *
  * @param  string   $path               image file
  * @param  int      $degree             rotete degrees
  * @param  string   $bgcolor            square background color in #rrggbb format
  * @param  string   $destformat         image destination format
  * @return string|false
  * @author nao-pon
  * @author Troex Nevelin
  **/
 protected function imgRotate($path, $degree, $bgcolor = '#ffffff', $destformat = null)
 {
     if (($s = @getimagesize($path)) == false) {
         return false;
     }
     $result = false;
     switch ($this->imgLib) {
         case 'imagick':
             try {
                 $img = new imagick($path);
             } catch (Exception $e) {
                 return false;
             }
             $img->rotateImage(new ImagickPixel($bgcolor), $degree);
             $result = $img->writeImage($path);
             return $result ? $path : false;
             break;
         case 'gd':
             if ($s['mime'] == 'image/jpeg') {
                 $img = imagecreatefromjpeg($path);
             } elseif ($s['mime'] == 'image/png') {
                 $img = imagecreatefrompng($path);
             } elseif ($s['mime'] == 'image/gif') {
                 $img = imagecreatefromgif($path);
             } elseif ($s['mime'] == 'image/xbm') {
                 $img = imagecreatefromxbm($path);
             }
             $degree = 360 - $degree;
             list($r, $g, $b) = sscanf($bgcolor, "#%02x%02x%02x");
             $bgcolor = imagecolorallocate($img, $r, $g, $b);
             $tmp = imageRotate($img, $degree, (int) $bgcolor);
             if ($destformat == 'jpg' || $destformat == null && $s['mime'] == 'image/jpeg') {
                 $result = imagejpeg($tmp, $path, 100);
             } else {
                 if ($destformat == 'gif' || $destformat == null && $s['mime'] == 'image/gif') {
                     $result = imagegif($tmp, $path, 7);
                 } else {
                     $result = imagepng($tmp, $path, 7);
                 }
             }
             imageDestroy($img);
             imageDestroy($tmp);
             return $result ? $path : false;
             break;
     }
     return false;
 }
开发者ID:serhatozles,项目名称:yii2-elfinder,代码行数:58,代码来源:elFinderVolumeDriver.class.php


示例19: imageCreateTrueColor

<?php

include 'phprandom.php';
$img = imageCreateTrueColor(256, 256);
$colors = array();
for ($i = 0; $i < 256; $i++) {
    $colors[$i] = imageColorAllocate($img, $i, $i, $i);
}
for ($i = 0; $i < 256; $i++) {
    $random = PHPRandom::getBinary(256);
    for ($j = 0; $j < 256; $j++) {
        $value = ord(substr($random, $j, 1));
        imageSetPixel($img, $i, $j, $colors[$value]);
    }
}
header('Content-Type: image/png');
imagePNG($img);
imageDestroy($img);
开发者ID:kijin,项目名称:phprandom,代码行数:18,代码来源:imagetest.php


示例20: mt_rand

    $randH = mt_rand(0, imageSY($im));
    imageSetPixel($im, $randW, $randH, $color);
}
imageSetThickness($im, 2);
$color = imageColorAllocate($im, 100, 100, 100);
imageLine($im, 10, 30, 130, 20, $color);
$color = imageColorAllocate($im, 70, 70, 70);
$n1 = mt_rand(0, 9);
imageTtfText($im, 25, 10, mt_rand(2, 10), mt_rand(25, 45), $color, "times.ttf", $n1);
$color = imageColorAllocate($im, 255, 0, 50);
$str = "ABCDIFGHIJKLMNOPKASTUVWXYZ";
$nw = mt_rand(0, 15);
$n2 = $str[$nw];
imageTtftext($im, 22, -10, mt_rand(25, 35), mt_rand(25, 45), $color, "times.ttf", $n2);
$color = imageColorAllocate($im, 50, 50, 50);
$n3 = mt_rand(0, 9);
imageTtfText($im, 25, 15, mt_rand(60, 70), mt_rand(25, 45), $color, "times.ttf", $n3);
$color = imageColorAllocate($im, 250, 250, 250);
$nw2 = mt_rand(15, 25);
$n4 = $str[$nw2];
imageTtfText($im, 22, 30, mt_rand(90, 100), mt_rand(25, 45), $color, "times.ttf", $n4);
$color = imageColorAllocate($im, 255, 220, 70);
$n5 = mt_rand(0, 9);
imageTtfText($im, 25, -20, mt_rand(115, 125), mt_rand(25, 45), $color, "times.ttf", $n5);
$n = $n1 . $n2 . $n3 . $n4 . $n5;
session_start();
$_SESSION['kap'] = md5(strtolower($n));
header("Content-type: image/jpeg");
imageJpeg($im);
imageDestroy($im);
开发者ID:echmaster,项目名称:data,代码行数:30,代码来源:dzim.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imageFill函数代码示例发布时间:2022-05-15
下一篇:
PHP imageCreateTrueColor函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap