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

PHP imageJPEG函数代码示例

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

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



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

示例1: saveImg

 public function saveImg($path)
 {
     // Resize
     if ($this->resize) {
         $this->output = ImageCreateTrueColor($this->xOutput, $this->yOutput);
         ImageCopyResampled($this->output, $this->input, 0, 0, 0, 0, $this->xOutput, $this->yOutput, $this->xInput, $this->yInput);
     }
     // Save JPEG
     if ($this->format == "JPG" or $this->format == "JPEG") {
         if ($this->resize) {
             imageJPEG($this->output, $path, $this->quality);
         } else {
             copy($this->src, $path);
         }
     } elseif ($this->format == "PNG") {
         if ($this->resize) {
             imagePNG($this->output, $path);
         } else {
             copy($this->src, $path);
         }
     } elseif ($this->format == "GIF") {
         if ($this->resize) {
             imageGIF($this->output, $path);
         } else {
             copy($this->src, $path);
         }
     }
 }
开发者ID:Mojolagbe2014,项目名称:mojoimipakiti,代码行数:28,代码来源:Imaging.php


示例2: thumbnail

function thumbnail($PicPathIn, $PicPathOut, $PicFilenameIn, $PicFilenameOut, $neueHoehe, $Quality)
{
    // Bilddaten ermitteln
    $size = getimagesize("{$PicPathIn}" . "{$PicFilenameIn}");
    $breite = $size[0];
    $hoehe = $size[1];
    $neueBreite = intval($breite * $neueHoehe / $hoehe);
    if ($size[2] == 1) {
        // GIF
        $altesBild = ImageCreateFromGIF("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        imageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
    if ($size[2] == 2) {
        // JPG
        $altesBild = ImageCreateFromJPEG("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
    if ($size[2] == 3) {
        // PNG
        $altesBild = ImageCreateFromPNG("{$PicPathIn}" . "{$PicFilenameIn}");
        $neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
        ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
    }
}
开发者ID:nchiapol,项目名称:ecamp,代码行数:29,代码来源:action_save_change_avatar.php


示例3: write

 public function write($path, $quality, $format = 'jpg')
 {
     if (!$this->image) {
         return false;
     }
     if ($format === 'png') {
         imagePNG($this->image, $path);
     } else {
         imageJPEG($this->image, $path, $quality);
     }
     return true;
 }
开发者ID:Norvares,项目名称:nemex,代码行数:12,代码来源:image.php


示例4: createThumbs

 public function createThumbs($thumb_size)
 {
     $thumb = imageCreateTrueColor($thumb_size['width'], $thumb_size['height']);
     if ($thumb === false) {
         throw new Exception('cannot create img_thumb file');
     }
     $resX = floor(imagesx($this->_orig_img) * ($thumb_size['height'] / imagesy($this->_orig_img)));
     $resY = $thumb_size['height'];
     imageAntiAlias($thumb, true);
     imagecopyresized($thumb, $this->_orig_img, 0, 0, 0, 0, $resX, $resY, imagesx($this->_orig_img), imagesy($this->_orig_img));
     if (!imageJPEG($thumb, $this->_save_path . 'thumbs_' . $this->_new_img_name, 100)) {
         imagedestroy($thumb);
         throw new Exception('cannot save img_thumbs file');
     }
     imagedestroy($thumb);
     return $this;
 }
开发者ID:alexposseda,项目名称:events,代码行数:17,代码来源:image.class.php


示例5: entry

 /**  
  * 输出验证码并把验证码的值保存的session中  
  */
 public static function entry()
 {
     // 图片宽(px)
     self::$imageL || (self::$imageL = self::$length * self::$fontSize * 1.5 + self::$fontSize * 1.5);
     // 图片高(px)
     self::$imageH || (self::$imageH = self::$fontSize * 2);
     // 建立一幅 self::$imageL x self::$imageH 的图像
     self::$_image = imagecreate(self::$imageL, self::$imageH);
     // 设置背景
     imagecolorallocate(self::$_image, self::$bg[0], self::$bg[1], self::$bg[2]);
     // 验证码字体随机颜色
     self::$_color = imagecolorallocate(self::$_image, mt_rand(1, 120), mt_rand(1, 120), mt_rand(1, 120));
     // 验证码使用随机字体,保证目录下有这些字体集
     $ttf = dirname(__FILE__) . '/ttfs/t' . mt_rand(1, 10) . '.ttf';
     if (self::$useNoise) {
         // 绘杂点
         self::_writeNoise();
     }
     if (self::$useCurve) {
         // 绘干扰线
         self::_writeCurve();
     }
     // 绘验证码
     $code = array();
     // 验证码
     $codeNX = 0;
     // 验证码第N个字符的左边距
     for ($i = 0; $i < self::$length; $i++) {
         $code[$i] = self::$codeSet[mt_rand(0, 28)];
         $codeNX += mt_rand(self::$fontSize * 1.2, self::$fontSize * 1.6);
         // 写一个验证码字符
         imagettftext(self::$_image, self::$fontSize, mt_rand(-40, 70), $codeNX, self::$fontSize * 1.5, self::$_color, $ttf, $code[$i]);
     }
     // 保存验证码
     isset($_SESSION) || session_start();
     $_SESSION[self::$seKey]['code'] = join('', $code);
     // 把验证码保存到session, 验证时注意是大写
     $_SESSION[self::$seKey]['time'] = time();
     // 验证码创建时间
     header('Pragma: no-cache');
     header("content-type: image/JPEG");
     // 输出图像
     imageJPEG(self::$_image);
     imagedestroy(self::$_image);
 }
开发者ID:akaiidle,项目名称:newborn,代码行数:48,代码来源:verify.php


示例6: save

 function save($save)
 {
     /* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
     $this->img["des"] = ImageCreateTrueColor($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}");
     } elseif ($this->img["format"] == "GIF") {
         //GIF
         imageGIF($this->img["des"], "{$save}");
     } elseif ($this->img["format"] == "WBMP") {
         //WBMP
         imageWBMP($this->img["des"], "{$save}");
     }
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:19,代码来源:ThumbNail.php


示例7: createNewImage

 private function createNewImage($newImg, $newName, $imgInfo)
 {
     switch ($imgInfo["type"]) {
         case 1:
             //gif
             $result = imageGif($newImg, $this->path . $newName);
             break;
         case 2:
             //jpg
             $result = imageJPEG($newImg, $this->path . $newName);
             break;
         case 3:
             //png
             $return = imagepng($newImg, $this->path . $newName);
             break;
     }
     imagedestroy($newImg);
     return $newName;
 }
开发者ID:Rockroc,项目名称:PHP,代码行数:19,代码来源:image.class.php


示例8: 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


示例9: 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


示例10: entry

 /**  
  * 输出验证码并把验证码的值保存的session中  
  */
 public static function entry()
 {
     // 图片宽(px)
     self::$imageL || (self::$imageL = self::$length * self::$fontSize * 1.5 + self::$fontSize * 1.5);
     // 图片高(px)
     self::$imageH || (self::$imageH = self::$fontSize * 2);
     // 建立一幅 self::$imageL x self::$imageH 的图像
     self::$_image = imagecreate(self::$imageL, self::$imageH);
     // 设置背景
     imagecolorallocate(self::$_image, self::$bg[0], self::$bg[1], self::$bg[2]);
     // 验证码字体随机颜色
     self::$_color = imagecolorallocate(self::$_image, mt_rand(1, 120), mt_rand(1, 120), mt_rand(1, 120));
     // 验证码使用随机字体,保证目录下有这些字体集
     $ttf = dirname(__FILE__) . '/ttfs/t' . mt_rand(1, 3) . '.ttf';
     if (self::$useNoise) {
         // 绘杂点
         self::_writeNoise();
     }
     if (self::$useCurve) {
         // 绘干扰线
         self::_writeCurve();
     }
     // 绘验证码
     $code = array();
     // 验证码
     $codeNX = 0;
     // 验证码第N个字符的左边距
     for ($i = 0; $i < self::$length; $i++) {
         $code[$i] = self::$codeSet[mt_rand(0, 28)];
         $codeNX += mt_rand(self::$fontSize * 1.2, self::$fontSize * 1.6);
         imagettftext(self::$_image, self::$fontSize, mt_rand(-40, 40), $codeNX, self::$fontSize * 1.5, self::$_color, $ttf, $code[$i]);
     }
     self::$code = join('', $code);
     // 输出图像
     imageJPEG(self::$_image);
     imagedestroy(self::$_image);
 }
开发者ID:hpuwang,项目名称:toro_web,代码行数:40,代码来源:verify.php


示例11: generate_thumbnail

/**
* generates a constrained image and returns the data stream
* Good for making thumbnails or just constraining all  uploaded images.
*
* @param path       str: path to temp image (eg. '/home/user/web/temp')
* @param tmp_file   str: the original filename( eg. foo.jpg )
* @param constrain  str: x or y constrain (eg. 'x')
* @param size       int: constrained dimension size (eg. '200')
* @param value      arr: array containing the artist and album name for each loop
* @return           str: the JPEG filename from GD
*/
function generate_thumbnail($path, $tmp_file, $constrain, $size, $value)
{
    $rights = 0755;
    //get the source image size
    if ($imagesize = getimagesize($path . '/' . $tmp_file)) {
        //figure out the scaling ratio
        switch ($constrain) {
            case 'x':
                $ratio = $size / $imagesize[0];
                break;
            case 'y':
                $ratio = $size / $imagesize[1];
                break;
        }
        //read source format
        switch (substr($tmp_file, -3)) {
            case 'jpg':
                $source = imagecreatefromjpeg($path . '/' . $tmp_file);
                break;
            case 'gif':
                $source = imagecreatefromgif($path . '/' . $tmp_file);
                break;
            case 'png':
                $source = imagecreatefrompng($path . '/' . $tmp_file);
                break;
        }
        //open new resource file
        if ($source) {
            //resample the image using the ratio
            $th_xdim = (int) floor($ratio * $imagesize[0]);
            $th_ydim = (int) floor($ratio * $imagesize[1]);
            $tempdest = imagecreatetruecolor($th_xdim, $th_ydim);
            //make a copy of the thumbnail image in server memory
            imagecopyresampled($tempdest, $source, 0, 0, 0, 0, $th_xdim, $th_ydim, imagesx($source), imagesy($source));
            //we're done with the source, so we'll purge it
            imagedestroy($source);
            //copy the proper JPEG source to the server and chmod it to 644
            imageJPEG($tempdest, $path . '/' . $size . '-' . $tmp_file);
            chmod($path . '/' . $size . '-' . $tmp_file, $rights);
            //finally, clean up the rest of image memory
            imagedestroy($tempdest);
            //return the new filename for moving
            return $size . '-' . $tmp_file;
        } else {
            echo 'could not load source image into GD for:' . $value['artist_name'] . '/' . $value['album_name'];
        }
    } else {
        echo 'GD could not get the image dimensions for the media: ' . $value['artist_name'] . '/' . $value['album_name'];
    }
}
开发者ID:Alenpiera,项目名称:streeme,代码行数:61,代码来源:artworkScanMeta.php


示例12: appendSourceInfo

 /**
  * Appends information about the source image to the thumbnail.
  * 
  * @param	string		$thumbnail
  * @return	string
  */
 protected function appendSourceInfo($thumbnail)
 {
     if (!function_exists('imageCreateFromString') || !function_exists('imageCreateTrueColor')) {
         return $thumbnail;
     }
     $imageSrc = imageCreateFromString($thumbnail);
     // get image size
     $width = imageSX($imageSrc);
     $height = imageSY($imageSrc);
     // increase height
     $heightDst = $height + self::$sourceInfoLineHeight * 2;
     // create new image
     $imageDst = imageCreateTrueColor($width, $heightDst);
     imageAlphaBlending($imageDst, false);
     // set background color
     $background = imageColorAllocate($imageDst, 102, 102, 102);
     imageFill($imageDst, 0, 0, $background);
     // copy image
     imageCopy($imageDst, $imageSrc, 0, 0, 0, 0, $width, $height);
     imageSaveAlpha($imageDst, true);
     // get font size
     $font = 2;
     $fontWidth = imageFontWidth($font);
     $fontHeight = imageFontHeight($font);
     $fontColor = imageColorAllocate($imageDst, 255, 255, 255);
     // write source info
     $line1 = $this->sourceName;
     // imageString supports only ISO-8859-1 encoded strings
     if (CHARSET != 'ISO-8859-1') {
         $line1 = StringUtil::convertEncoding(CHARSET, 'ISO-8859-1', $line1);
     }
     // truncate text if necessary
     $maxChars = floor($width / $fontWidth);
     if (strlen($line1) > $maxChars) {
         $line1 = $this->truncateSourceName($line1, $maxChars);
     }
     $line2 = $this->sourceWidth . 'x' . $this->sourceHeight . ' ' . FileUtil::formatFilesize($this->sourceSize);
     // write line 1
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line1) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line1) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line1, $fontColor);
     // write line 2
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = self::$sourceInfoLineHeight + intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line2) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line2) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line2, $fontColor);
     // output image
     ob_start();
     if ($this->imageType == 1 && function_exists('imageGIF')) {
         @imageGIF($imageDst);
         $this->mimeType = 'image/gif';
     } else {
         if (($this->imageType == 1 || $this->imageType == 3) && function_exists('imagePNG')) {
             @imagePNG($imageDst);
             $this->mimeType = 'image/png';
         } else {
             if (function_exists('imageJPEG')) {
                 @imageJPEG($imageDst, null, 90);
                 $this->mimeType = 'image/jpeg';
             } else {
                 return false;
             }
         }
     }
     @imageDestroy($imageDst);
     $thumbnail = ob_get_contents();
     ob_end_clean();
     return $thumbnail;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:88,代码来源:Thumbnail.class.php


示例13: __write

 /**
  * Write the image after being processed
  *
  * @param Asido_TMP &$tmp
  * @return boolean
  * @access protected
  */
 function __write(&$tmp)
 {
     // try to guess format from extension
     //
     if (!$tmp->save) {
         $p = pathinfo($tmp->target_filename);
         ($tmp->save = $this->__mime_metaphone[metaphone($p['extension'])]) || ($tmp->save = $this->__mime_soundex[soundex($p['extension'])]);
     }
     $result = false;
     switch ($tmp->save) {
         case 'image/gif':
             imageTrueColorToPalette($tmp->target, true, 256);
             $result = @imageGIF($tmp->target, $tmp->target_filename);
             break;
         case 'image/jpeg':
             $result = @imageJPEG($tmp->target, $tmp->target_filename, ASIDO_GD_JPEG_QUALITY);
             break;
         case 'image/wbmp':
             $result = @imageWBMP($tmp->target, $tmp->target_filename);
             break;
         default:
         case 'image/png':
             imageSaveAlpha($tmp->target, true);
             imageAlphaBlending($tmp->target, false);
             $result = @imagePNG($tmp->target, $tmp->target_filename);
             break;
     }
     @$this->__destroy_source($tmp);
     @$this->__destroy_target($tmp);
     return $result;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:38,代码来源:class.driver.gd.php


示例14: create_watermark

 function create_watermark($file)
 {
     //文件不存在则返回
     if (!file_exists($this->watermark_file) || !file_exists($file)) {
         return;
     }
     if (!function_exists('getImageSize')) {
         return;
     }
     //检查GD支持的文件类型
     $gd_allow_types = array();
     if (function_exists('ImageCreateFromGIF')) {
         $gd_allow_types['image/gif'] = 'ImageCreateFromGIF';
     }
     if (function_exists('ImageCreateFromPNG')) {
         $gd_allow_types['image/png'] = 'ImageCreateFromPNG';
     }
     if (function_exists('ImageCreateFromJPEG')) {
         $gd_allow_types['image/jpeg'] = 'ImageCreateFromJPEG';
     }
     //获取文件信息
     $fileinfo = getImageSize($file);
     $wminfo = getImageSize($this->watermark_file);
     if ($fileinfo[0] < $wminfo[0] || $fileinfo[1] < $wminfo[1]) {
         return;
     }
     if (array_key_exists($fileinfo['mime'], $gd_allow_types)) {
         if (array_key_exists($wminfo['mime'], $gd_allow_types)) {
             // 从文件创建图像
             $temp = $gd_allow_types[$fileinfo['mime']]($file);
             $temp_wm = $gd_allow_types[$wminfo['mime']]($this->watermark_file);
             // 水印位置
             switch ($this->watermark_pos) {
                 case 1:
                     //顶部居左
                     $dst_x = 0;
                     $dst_y = 0;
                     break;
                 case 2:
                     //顶部居中
                     $dst_x = ($fileinfo[0] - $wminfo[0]) / 2;
                     $dst_y = 0;
                     break;
                 case 3:
                     //顶部居右
                     $dst_x = $fileinfo[0];
                     $dst_y = 0;
                     break;
                 case 4:
                     //底部居左
                     $dst_x = 0;
                     $dst_y = $fileinfo[1];
                     break;
                 case 5:
                     //底部居中
                     $dst_x = ($fileinfo[0] - $wminfo[0]) / 2;
                     $dst_y = $fileinfo[1];
                     break;
                 case 6:
                     //底部居右
                     $dst_x = $fileinfo[0] - $wminfo[0];
                     $dst_y = $fileinfo[1] - $wminfo[1];
                     break;
                 default:
                     //随机
                     $dst_x = mt_rand(0, $fileinfo[0] - $wminfo[0]);
                     $dst_y = mt_rand(0, $fileinfo[1] - $wminfo[1]);
             }
             if (function_exists('ImageAlphaBlending')) {
                 ImageAlphaBlending($temp_wm, True);
             }
             // 设定图像的混色模式
             if (function_exists('ImageSaveAlpha')) {
                 ImageSaveAlpha($temp_wm, True);
             }
             // 保存完整的 alpha 通道信息
             //为图像添加水印
             if (function_exists('imageCopyMerge')) {
                 ImageCopyMerge($temp, $temp_wm, $dst_x, $dst_y, 0, 0, $wminfo[0], $wminfo[1], $this->watermark_trans);
             } else {
                 ImageCopyMerge($temp, $temp_wm, $dst_x, $dst_y, 0, 0, $wminfo[0], $wminfo[1]);
             }
             // 保存图片
             switch ($fileinfo['mime']) {
                 case 'image/jpeg':
                     @imageJPEG($temp, $file);
                     break;
                 case 'image/png':
                     @imagePNG($temp, $file);
                     break;
                 case 'image/gif':
                     @imageGIF($temp, $file);
                     break;
             }
             // 销毁零时图像
             @imageDestroy($temp);
             @imageDestroy($temp_wm);
         }
     }
 }
开发者ID:aidear,项目名称:100event,代码行数:100,代码来源:upload3.php


示例15: makewatermark

function makewatermark($srcfile)
{
    global $_SCONFIG;
    if ($_SCONFIG['watermark'] && function_exists('imageCreateFromJPEG') && function_exists('imageCreateFromPNG') && function_exists('imageCopyMerge')) {
        $srcfile = A_DIR . '/' . $srcfile;
        $watermark_file = $_SCONFIG['watermarkfile'];
        $watermarkstatus = $_SCONFIG['watermarkstatus'];
        $fileext = fileext($watermark_file);
        $ispng = $fileext == 'png' ? true : false;
        $attachinfo = @getimagesize($srcfile);
        if (!empty($attachinfo) && is_array($attachinfo) && $attachinfo[2] != 1 && $attachinfo['mime'] != 'image/gif') {
        } else {
            return '';
        }
        $watermark_logo = $ispng ? @imageCreateFromPNG($watermark_file) : @imageCreateFromGIF($watermark_file);
        if (!$watermark_logo) {
            return '';
        }
        $logo_w = imageSX($watermark_logo);
        $logo_h = imageSY($watermark_logo);
        $img_w = $attachinfo[0];
        $img_h = $attachinfo[1];
        $wmwidth = $img_w - $logo_w;
        $wmheight = $img_h - $logo_h;
        if (is_readable($watermark_file) && $wmwidth > 100 && $wmheight > 100) {
            switch ($attachinfo['mime']) {
                case 'image/jpeg':
                    $dst_photo = imageCreateFromJPEG($srcfile);
                    break;
                case 'image/gif':
                    $dst_photo = imageCreateFromGIF($srcfile);
                    break;
                case 'image/png':
                    $dst_photo = imageCreateFromPNG($srcfile);
                    break;
                default:
                    break;
            }
            switch ($watermarkstatus) {
                case 1:
                    $x = +5;
                    $y = +5;
                    break;
                case 2:
                    $x = ($img_w - $logo_w) / 2;
                    $y = +5;
                    break;
                case 3:
                    $x = $img_w - $logo_w - 5;
                    $y = +5;
                    break;
                case 4:
                    $x = +5;
                    $y = ($img_h - $logo_h) / 2;
                    break;
                case 5:
                    $x = ($img_w - $logo_w) / 2;
                    $y = ($img_h - $logo_h) / 2;
                    break;
                case 6:
                    $x = $img_w - $logo_w - 5;
                    $y = ($img_h - $logo_h) / 2;
                    break;
                case 7:
                    $x = +5;
                    $y = $img_h - $logo_h - 5;
                    break;
                case 8:
                    $x = ($img_w - $logo_w) / 2;
                    $y = $img_h - $logo_h - 5;
                    break;
                case 9:
                    $x = $img_w - $logo_w - 5;
                    $y = $img_h - $logo_h - 5;
                    break;
            }
            if ($ispng) {
                $watermark_photo = imagecreatetruecolor($img_w, $img_h);
                imageCopy($watermark_photo, $dst_photo, 0, 0, 0, 0, $img_w, $img_h);
                imageCopy($watermark_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
                $dst_photo = $watermark_photo;
            } else {
                imageAlphaBlending($watermark_logo, true);
                imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $_SCONFIG['watermarktrans']);
            }
            switch ($attachinfo['mime']) {
                case 'image/jpeg':
                    imageJPEG($dst_photo, $srcfile, $_SCONFIG['watermarkjpgquality']);
                    break;
                case 'image/gif':
                    imageGIF($dst_photo, $srcfile);
                    break;
                case 'image/png':
                    imagePNG($dst_photo, $srcfile);
                    break;
            }
        }
    }
}
开发者ID:hongz1125,项目名称:devil,代码行数:99,代码来源:upload.func.php


示例16: convertImage

 function convertImage($type)
 {
     /* check the converted image type availability,
        if it is not available, it will be casted to jpeg :) */
     $validtype = $this->validateType($type);
     if ($this->output) {
         /* show the image  */
         switch ($validtype) {
             case 'jpeg':
             case 'jpg':
                 header("Content-type: image/jpeg");
                 if ($this->imtype == 'gif' or $this->imtype == 'png') {
                     $image = $this->replaceTransparentWhite($this->im);
                     imageJPEG($image);
                 } else {
                     imageJPEG($this->im);
                 }
                 break;
             case 'gif':
                 header("Content-type: image/gif");
                 imageGIF($this->im);
                 break;
             case 'png':
                 header("Content-type: image/png");
                 imagePNG($this->im);
                 break;
             case 'wbmp':
                 header("Content-type: image/vnd.wap.wbmp");
                 imageWBMP($this->im);
                 break;
             case 'swf':
                 header("Content-type: application/x-shockwave-flash");
                 $this->imageSWF($this->im);
                 break;
         }
         // Memory cleanup
         @imagedestroy($this->im);
     } else {
         /* save the image  */
         switch ($validtype) {
             case 'jpeg':
             case 'jpg':
                 if ($this->imtype == 'gif' or $this->imtype == 'png') {
                     /* replace transparent with white */
                     $image = $this->replaceTransparentWhite($this->im);
                     imageJPEG($image, $this->finalFilePath . $this->imname . ".jpg");
                 } else {
                     imageJPEG($this->im, $this->finalFilePath . $this->imname . ".jpg");
                 }
                 break;
             case 'gif':
                 imageGIF($this->im, $this->finalFilePath . $this->imname . ".gif");
                 break;
             case 'png':
                 imagePNG($this->im, $this->finalFilePath . $this->imname . ".png");
                 break;
             case 'wbmp':
                 imageWBMP($this->im, $this->finalFilePath . $this->imname . ".wbmp");
                 break;
             case 'swf':
                 $this->imageSWF($this->im, $this->finalFilePath . $this->imname . ".swf");
                 break;
         }
         // Memory cleanup
         @imagedestroy($this->im);
     }
 }
开发者ID:hyrmedia,项目名称:modules,代码行数:67,代码来源:class.imageconverter.inc.php


示例17: watermark

 function watermark($target, $watermark_file, $ext, $watermarkstatus = 9, $watermarktrans = 50)
 {
     $gdsurporttype = array();
     if (function_exists('imageAlphaBlending') && function_exists('getimagesize')) {
         if (function_exists('imageGIF')) {
             $gdsurporttype[] = 'gif';
         }
         if (function_exists('imagePNG')) {
             $gdsurporttype[] = 'png';
         }
         if (function_exists('imageJPEG')) {
             $gdsurporttype[] = 'jpg';
             $gdsurporttype[] = 'jpeg';
         }
     }
     if ($gdsurporttype && in_array($ext, $gdsurporttype)) {
         $attachinfo = getimagesize($target);
         $watermark_logo = imageCreateFromGIF($watermark_file);
         $logo_w = imageSX($watermark_logo);
         $logo_h = imageSY($watermark_logo);
         $img_w = $attachinfo[0];
         $img_h = $attachinfo[1];
         $wmwidth = $img_w - $logo_w;
         $wmheight = $img_h - $logo_h;
         $animatedgif = 0;
         if ($attachinfo['mime'] == 'image/gif') {
             $fp = fopen($target, 'rb');
             $targetcontent = fread($fp, 9999999);
             fclose($fp);
             $animatedgif = strpos($targetcontent, 'NETSCAPE2.0') === FALSE ? 0 : 1;
         }
         if ($watermark_logo && $wmwidth > 10 && $wmheight > 10 && !$animatedgif) {
             switch ($attachinfo['mime']) {
                 case 'image/jpeg':
                     $dst_photo = imageCreateFromJPEG($target);
                     break;
                 case 'image/gif':
                     $dst_photo = imageCreateFromGIF($target);
                     break;
                 case 'image/png':
                     $dst_photo = imageCreateFromPNG($target);
                     break;
             }
             switch ($watermarkstatus) {
                 case 1:
                     $x = +5;
                     $y = +5;
                     break;
                 case 2:
                     $x = ($logo_w + $img_w) / 2;
                     $y = +5;
                     break;
                 case 3:
                     $x = $img_w - $logo_w - 5;
                     $y = +5;
                     break;
                 case 4:
                     $x = +5;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 5:
                     $x = ($logo_w + $img_w) / 2;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 6:
                     $x = $img_w - $logo_w;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 7:
                     $x = +5;
                     $y = $img_h - $logo_h - 5;
                     break;
                 case 8:
                     $x = ($logo_w + $img_w) / 2;
                     $y = $img_h - $logo_h;
                     break;
                 case 9:
                     $x = $img_w - $logo_w - 5;
                     $y = $img_h - $logo_h - 5;
                     break;
             }
             imageAlphaBlending($watermark_logo, FALSE);
             imagesavealpha($watermark_logo, TRUE);
             imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $watermarktrans);
             switch ($attachinfo['mime']) {
                 case 'image/jpeg':
                     imageJPEG($dst_photo, $target);
                     break;
                 case 'image/gif':
                     imageGIF($dst_photo, $target);
                     break;
                 case 'image/png':
                     imagePNG($dst_photo, $target);
                     break;
             }
         }
     }
 }
开发者ID:softhui,项目名称:discuz,代码行数:98,代码来源:upload.class.php


示例18: convertImage

 function convertImage($type)
 {
     /* check the converted image type availability,
        if it is not available, it will be casted to jpeg :) */
     $validtype = $this->validateType($type);
     if ($this->output) {
         /* show the image  */
         switch ($validtype) {
             case 'jpeg':
                 // Added jpe
             // Added jpe
             case 'jpe':
             case 'jpg':
                 header("Content-type: image/jpeg");
                 if ($this->imtype == 'gif' or $this->imtype == 'png') {
                     $image = $this->replaceTransparentWhite($this->im);
                     @imageJPEG($image);
                 } else {
                     @imageJPEG($this->im);
                 }
                 break;
             case 'gif':
                 header("Content-type: image/gif");
                 @imageGIF($this->im);
                 break;
             case 'png':
                 header("Content-type: image/png");
                 @imagePNG($this->im);
                 break;
             case 'wbmp':
                 header("Content-type: image/vnd.wap.wbmp");
                 @imageWBMP($this->im);
                 break;
             case 'swf':
                 header("Content-type: application/x-shockwave-flash");
                 $this->imageSWF($this->im);
                 break;
         }
     } else {
         // Added Support vor different directory
         if (DEFINED('V_TEMP_DIR')) {
             $this->newimname = V_TEMP_DIR . $this->imname . '.' . $validtype;
         } else {
             $this->newimname = $this->imname . '.' . $validtype;
         }
         /* save the image  */
         switch ($validtype) {
             case 'jpeg':
                 // Added jpe
             // Added jpe
             case 'jpe':
             case 'jpg':
                 if ($this->imtype == 'gif' or $this->imtype == 'png') {
                     /* replace transparent with white */
                     $image = $this->replaceTransparentWhite($this->im);
                     @imageJPEG($image, $this->newimname);
                 } else {
                     @imageJPEG($this->im, $this->newimname);
                 }
                 break;
             case 'gif':
                 @imageGIF($this->im, $this->newimname);
                 break;
             case 'png':
                 @imagePNG($this->im, $this->newimname);
                 break;
             case 'wbmp':
                 @imageWBMP($this->im, $this->newimname);
                 break;
             case 'swf':
                 $this->imageSWF($this->im, $this->newimname);
                 break;
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:75,代码来源:class.imageconverter.php


示例19: resizeImage


//.........这里部分代码省略.........
         } else {
             $tmp_img;
             list($width, $height) = getimagesize($cInput);
             if ($xType == 'square' && $width != $height) {
                 $biggestSide = '';
                 $cropPercent = 0.5;
                 $cropWidth = 0;
                 $cropHeight = 0;
                 $c1 = array();
                 if ($width > $height) {
                     $biggestSide = $width;
                     $cropWidth = round($biggestSide * $cropPercent);
                     $cropHeight = round($biggestSide * $cropPercent);
                     $c1 = array("x" => ($width - $cropWidth) / 2, "y" => ($height - $cropHeight) / 2);
                 } else {
                     $biggestSide = $height;
                     $cropWidth = round($biggestSide * $cropPercent);
                     $cropHeight = round($biggestSide * $cropPercent);
                     $c1 = array("x" => ($width - $cropWidth) / 2, "y" => ($height - $cropHeight) / 7);
                 }
                 $thumbSize = $nH;
                 if ($cType == 'image/gif') {
                     $tmp_img = imagecreate($thumbSize, $thumbSize);
                     imagecolortransparent($tmp_img, imagecolorallocate($tmp_img, 0, 0, 0));
                     imagecopyresized($tmp_img, $src_img, 0, 0, $c1['x'], $c1['y'], $thumbSize, $thumbSize, $cropWidth, $cropHeight);
                 } elseif ($cType == 'image/x-png') {
                     $tmp_img = imagecreatetruecolor($thumbSize, $thumbSize);
                     imagecopyresampled($tmp_img, $src_img, 0, 0, $c1['x'], $c1['y'], $thumbSize, $thumbSize, $cropWidth, $cropHeight);
                 } elseif ($cType == 'image/bmp') {
  

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imageJpeg函数代码示例发布时间:2022-05-15
下一篇:
PHP imageGif函数代码示例发布时间: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