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


PHP imagedestroy函数代码示例

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


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

示例1: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php

示例2: load

 static function load($filename)
 {
     $info = getimagesize($filename);
     list($width, $height) = $info;
     if (!$width || !$height) {
         return null;
     }
     $image = null;
     switch ($info['mime']) {
         case 'image/gif':
             $image = imagecreatefromgif($filename);
             break;
         case 'image/jpeg':
             $image = imagecreatefromjpeg($filename);
             break;
         case 'image/png':
             $image = imagecreatetruecolor($width, $height);
             $white = imagecolorallocate($image, 255, 255, 255);
             imagefill($image, 0, 0, $white);
             $png = imagecreatefrompng($filename);
             imagealphablending($png, true);
             imagesavealpha($png, true);
             imagecopy($image, $png, 0, 0, 0, 0, $width, $height);
             imagedestroy($png);
             break;
     }
     if ($image) {
         return new image($image, $width, $height);
     } else {
         return null;
     }
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:32,代码来源:image.php

示例3: GetPartialImage

function GetPartialImage($url)
{
	$W = 150;
	$H = 130;
	$F = 80;
	$STEP = 1.0 / $F;
	$im = imagecreatefromjpeg($url);
	$dest = imagecreatetruecolor($W, $H);
	imagecopy($dest, $im, 0, 0, 35, 40, $W, $H);
	
	$a = 1;
	for( $y = $H - $F; $y < $H; $y++ )
	{
		for ( $x = 0; $x < $W; $x++ )
		{
			$i = imagecolorat($dest, $x, $y);
			$c = imagecolorsforindex($dest, $i);
			$c = imagecolorallocate($dest, 
				a($c['red'], $a),
				a($c['green'], $a), 
				a($c['blue'], $a)
			);
			imagesetpixel($dest, $x, $y, $c);
		}
		$a -= $STEP;
	}
	
	header('Content-type: image/png');
	imagepng($dest);
	imagedestroy($dest);
	imagedestroy($im);
}
开发者ID:ryanknu,项目名称:Cuber,代码行数:32,代码来源:image.php

示例4: load

 public function load($filename, $return_data = false)
 {
     extract(parent::load($filename, $return_data));
     $return = false;
     $image_extension == 'jpg' and $image_extension = 'jpeg';
     if (!$return_data) {
         $this->image_data !== null and imagedestroy($this->image_data);
         $this->image_data = null;
     }
     // Check if the function exists
     if (function_exists('imagecreatefrom' . $image_extension)) {
         // Create a new transparent image.
         $sizes = $this->sizes($image_fullpath);
         $tmpImage = call_user_func('imagecreatefrom' . $image_extension, $image_fullpath);
         $image = $this->create_transparent_image($sizes->width, $sizes->height, $tmpImage);
         if (!$return_data) {
             $this->image_data = $image;
             $return = true;
         } else {
             $return = $image;
         }
         $this->debug('', "<strong>Loaded</strong> <code>" . $image_fullpath . "</code> with size of " . $sizes->width . "x" . $sizes->height);
     } else {
         throw new \RuntimeException("Function imagecreatefrom" . $image_extension . "() does not exist (Missing GD?)");
     }
     return $return_data ? $return : $this;
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:27,代码来源:gd.php

示例5: fill_watermark

 public function fill_watermark()
 {
     $image = $this->editor->get_image();
     $size = $this->editor->get_size();
     list($mask_width, $mask_height, $mask_type, $mask_attr) = getimagesize($this->args['mask']);
     switch ($mask_type) {
         case 1:
             $mask = imagecreatefromgif($this->args['mask']);
             break;
         case 2:
             $mask = imagecreatefromjpeg($this->args['mask']);
             break;
         case 3:
             $mask = imagecreatefrompng($this->args['mask']);
             break;
     }
     imagealphablending($image, true);
     if (strpos($this->args['position'], 'left') !== false) {
         $left = $this->args['padding'];
     } else {
         $left = $size['width'] - $mask_width - $this->args['padding'];
     }
     if (strpos($this->args['position'], 'top') !== false) {
         $top = $this->args['padding'];
     } else {
         $top = $size['height'] - $mask_height - $this->args['padding'];
     }
     imagecopy($image, $mask, $left, $top, 0, 0, $mask_width, $mask_height);
     $this->editor->update_image($image);
     imagedestroy($mask);
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:31,代码来源:wpthumb.watermark.php

示例6: render

 /**
  * Displays the image
  *
  * @param	integer	$quality	image render quality 1-100, default 100
  * @access	public
  * @return	void
  */
 function render($quality = 100)
 {
     header('Content-type: image/' . $this->type);
     @imageinterlace($this->handle, 1);
     @imagegif($this->handle, NULL, $quality);
     @imagedestroy($this->handle);
 }
开发者ID:sauruscms,项目名称:Saurus-CMS-Community-Edition,代码行数:14,代码来源:GotchaGIF.class.php

示例7: thumb

function thumb($filename, $destination = null, $dst_w = null, $dst_h = null, $isReservedSource = false, $scale = 0.5)
{
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    //image_50/sdfsdkfjkelwkerjle.jpg
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, true);
    }
    $dstFilename = $destination == null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
开发者ID:Wumingla,项目名称:shopImooc,代码行数:26,代码来源:resizeImage2.php

示例8: save

 public function save()
 {
     $maxHeight = 0;
     $width = 0;
     foreach ($this->_segmentsArray as $segment) {
         $maxHeight = max($maxHeight, $segment->height);
         $width += $segment->width;
     }
     // create our canvas
     $img = imagecreatetruecolor($width, $maxHeight);
     $background = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $background);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     // start placing our images on a single x axis
     $xPos = 0;
     foreach ($this->_segmentsArray as $segment) {
         $tmp = imagecreatefromjpeg($segment->pathToImage);
         imagecopy($img, $tmp, $xPos, 0, 0, 0, $segment->width, $segment->height);
         $xPos += $segment->width;
         imagedestroy($tmp);
     }
     // create our final output image.
     imagepng($img, $this->_saveToPath);
 }
开发者ID:ejacobs,项目名称:css-sprite,代码行数:25,代码来源:CssSprite.php

示例9: getCode

function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php

示例10: hacknrollify

function hacknrollify($picfilename)
{
    $logofilename = "logo.png";
    $logoPicPath = "logopics/" . $logofilename;
    $originalPicPath = "originalpics/" . $picfilename;
    $editedfilename = "hnr_" . $picfilename;
    $editedPicPath = "editedpics/" . $editedfilename;
    // read the original image from file
    $profilepic = imagecreatefromjpeg($originalPicPath);
    $profilepicWidth = imagesx($profilepic);
    $profilepicHeight = imagesy($profilepic);
    // create the black image overlay
    $blackoverlay = imagecreate($profilepicWidth, $profilepicHeight);
    imagecolorallocate($blackoverlay, 0, 0, 0);
    // then merge the black and profilepic
    imagecopymerge($profilepic, $blackoverlay, 0, 0, 0, 0, $profilepicWidth, $profilepicHeight, 50);
    imagedestroy($blackoverlay);
    // merge the resized logo
    $logo = resizeImage($logoPicPath, $profilepicWidth - 80, 999999);
    imageAlphaBlending($logo, false);
    imageSaveAlpha($logo, true);
    $logoWidth = imagesx($logo);
    $logoHeight = imagesy($logo);
    $verticalOffset = $profilepicHeight / 2 - $logoHeight / 2;
    $horizontalOffset = 40;
    imagecopyresampled($profilepic, $logo, $horizontalOffset, $verticalOffset, 0, 0, $logoWidth, $logoHeight, $logoWidth, $logoHeight);
    $mergeSuccess = imagejpeg($profilepic, $editedPicPath);
    if (!$mergeSuccess) {
        echo "Image merge failed!";
    }
    imagedestroy($profilepic);
    imagedestroy($logo);
    return $editedPicPath;
}
开发者ID:nicholaslum444,项目名称:HacknRollify,代码行数:34,代码来源:lib_hacknrollify.php

示例11: createthumb

function createthumb($originalImage, $new_w, $new_h)
{
    $src_img = imagecreatefromjpeg("uploads/" . $originalImage);
    # Add the _t to our image name
    list($imageName, $extension) = explode(".", $originalImage);
    $newName = $imageName . "_t." . $extension;
    # Maintain proportions
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    if ($old_x > $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $old_y * ($new_h / $old_x);
    }
    if ($old_x < $old_y) {
        $thumb_w = $old_x * ($new_w / $old_y);
        $thumb_h = $new_h;
    }
    if ($old_x == $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $new_h;
    }
    # Create destination-image-resource
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    # Copy source-image-resource to destination-image-resource
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    # Create the final image from the destination-image-resource
    imagejpeg($dst_img, "uploads/" . $newName);
    # Delete our image-resources
    imagedestroy($dst_img);
    imagedestroy($src_img);
    # Show results
    return $newName;
}
开发者ID:ritarafaeli,项目名称:notes,代码行数:33,代码来源:uploaderExample_functions.php

示例12: saveinfo

 function saveinfo()
 {
     $juser =& JFactory::getUser();
     if ($juser->guest) {
         $error = 'Bạn phải đăng nhập để thực hiện chức năng này';
         $this->setError($error);
         return false;
     }
     $post = JRequest::get('post');
     $data = array();
     $data['user_id'] = $juser->id;
     $data['couple_name'] = $post['couple_name'];
     $data['address'] = $post['address'];
     $data['country'] = $post['country'];
     if (isset($_FILES['avatar']) && $_FILES['avatar']['error'] == 0) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'thumb.php';
         $p = manThumb::resize($_FILES['avatar']['tmp_name'], 96, 96);
         $name = 'avatar_' . $juser->id . '.jpg';
         $file = JPATH_ROOT . DS . 'images' . DS . 'wedding' . DS . 'avatar' . DS . $name;
         imagejpeg($p, $file, 90);
         imagedestroy($p);
         $data['avatar'] = 'images/wedding/avatar/' . $name;
     }
     $row =& $this->getTable('users');
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
开发者ID:ngxuanmui,项目名称:hanhphuc.vn,代码行数:34,代码来源:profile.php

示例13: resizer

function resizer($image)
{
    $name = md5(sha1(date('d-m-y H:i:s') . $image['tmp_name']));
    $type = $image['type'];
    switch ($type) {
        case "image/jpeg":
            $img = imagecreatefromjpeg($image['tmp_name']);
            break;
        case "image/png":
            $img = imagecreatefrompng($image['tmp_name']);
            break;
    }
    $x = imagesx($img);
    $y = imagesy($img);
    $height = 150 * $y / $x;
    $new = imagecreatetruecolor(150, $height);
    imagecopyresampled($new, $img, 0, 0, 0, 0, 150, $height, $x, $y);
    switch ($type) {
        case "image/jpeg":
            $local = "../assets/img/crudpartners/{$name}" . ".jpg";
            imagejpeg($new, $local);
            break;
        case "image/png":
            $local = "../assets/img/crudpartners/{$name}" . ".png";
            imagejpeg($new, $local);
            break;
    }
    imagedestroy($img);
    imagedestroy($new);
    return $local;
}
开发者ID:iagosilvany,项目名称:projeto2,代码行数:31,代码来源:partners_image.php

示例14: upload

function upload($tmp, $name, $nome, $larguraP, $pasta)
{
    $ext = strtolower(end(explode('.', $name)));
    if ($ext == 'jpg') {
        $img = imagecreatefromjpeg($tmp);
    } elseif ($ext == 'gif') {
        $img = imagecreatefromgif($tmp);
    } else {
        $img = imagecreatefrompng($tmp);
    }
    $x = imagesx($img);
    $y = imagesy($img);
    $largura = $x > $larguraP ? $larguraP : $x;
    $altura = $largura * $y / $x;
    if ($altura > $larguraP) {
        $altura = $larguraP;
        $largura = $altura * $x / $y;
    }
    $nova = imagecreatetruecolor($largura, $altura);
    imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
    imagejpeg($nova, "{$pasta}/{$nome}");
    imagedestroy($img);
    imagedestroy($nova);
    return $nome;
}
开发者ID:mauriliovilela,项目名称:ser-social,代码行数:25,代码来源:funcoes.php

示例15: createImageKey

 public function createImageKey($user, $dblink)
 {
     if ($stm = $dblink->prepare("SELECT 2fa_imgname FROM  " . TABLE_USERS . " WHERE email = ?")) {
         $stm->execute(array($user));
         $row = $stm->fetch();
         $stm = NULL;
         $file = 'uploads/2fa/' . $row['2fa_imgname'];
     }
     $im = new Image();
     $imageclean = $im->loadLocalFile($file);
     $imagekey = $im->embedStegoKey($imageclean);
     $stegoKey = $im->stegoKey;
     $hash = password_hash($stegoKey, PASSWORD_DEFAULT);
     if ($stm = $dblink->prepare("UPDATE " . TABLE_USERS . " SET 2fa_hash = ? WHERE email = ?")) {
         $stm->execute(array($hash, $user));
         $stm = NULL;
     }
     if (ob_get_level()) {
         ob_end_clean();
     }
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=KeyImage.png');
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     //header('Content-Length: ' . filesize($file));
     $ok = imagepng($imagekey);
     //, NULL, 9
     imagedestroy($imagekey);
     return $ok;
 }
开发者ID:semaster,项目名称:2FAuth-Steganography,代码行数:33,代码来源:AccountSetup2fa.php


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