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

PHP imageGIF函数代码示例

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

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



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

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


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


示例3: __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;
     $imgContent = null;
     switch ($tmp->save) {
         case 'image/gif':
             imageTrueColorToPalette($tmp->target, true, 256);
             ob_start();
             $result = @imageGIF($tmp->target);
             $imgContent = ob_get_clean();
             break;
         case 'image/jpeg':
             ob_start();
             $result = @imageJPEG($tmp->target, null, ASIDO_GD_JPEG_QUALITY);
             $imgContent = ob_get_clean();
             break;
         case 'image/wbmp':
             ob_start();
             $result = @imageWBMP($tmp->target);
             $imgContent = ob_get_clean();
             break;
         default:
         case 'image/png':
             imageSaveAlpha($tmp->target, true);
             imageAlphaBlending($tmp->target, false);
             ob_start();
             $result = @imagePNG($tmp->target, null, ASIDO_GD_PNG_QUALITY);
             $imgContent = ob_get_clean();
             break;
     }
     if ($result) {
         jimport('joomla.filesystem.file');
         JFile::write($tmp->target_filename, $imgContent);
     }
     @$this->__destroy_source($tmp);
     @$this->__destroy_target($tmp);
     return $result;
 }
开发者ID:ashanrupasinghe,项目名称:dnp,代码行数:51,代码来源:class.driver.gd.php


示例4: create


//.........这里部分代码省略.........
                         $finalHeight = $height;
                     } else {
                         if ($crop && $wDiff > $hDiff) {
                             //resize down to target height, THEN crop off extra width
                             $finalWidth = $oWidth / $hDiff;
                             $finalHeight = $height;
                             $do_crop_x = true;
                         } else {
                             if ($crop) {
                                 //resize down to target width, THEN crop off extra height
                                 $finalWidth = $width;
                                 $finalHeight = $oHeight / $wDiff;
                                 $do_crop_y = true;
                             }
                         }
                     }
                 }
             }
         }
     }
     //Calculate cropping to center image
     if ($do_crop_x) {
         /*
         //Get half the difference between scaled width and target width,
         // and crop by starting the copy that many pixels over from the left side of the source (scaled) image.
         $nudge = ($width / 10); //I have *no* idea why the width isn't centering exactly -- this seems to fix it though.
         $crop_src_x = ($finalWidth / 2.00) - ($width / 2.00) + $nudge;
         */
         $crop_src_x = round(($oWidth - $width * $oHeight / $height) * 0.5);
     }
     if ($do_crop_y) {
         /*
         //Calculate cropping...
         //Get half the difference between scaled height and target height,
         // and crop by starting the copy that many pixels down from the top of the source (scaled) image.
         $crop_src_y = ($finalHeight / 2.00) - ($height / 2.00);
         */
         $crop_src_y = round(($oHeight - $height * $oWidth / $width) * 0.5);
     }
     //create "canvas" to put new resized and/or cropped image into
     if ($crop) {
         $image = @imageCreateTrueColor($width, $height);
     } else {
         $image = @imageCreateTrueColor($finalWidth, $finalHeight);
     }
     switch ($imageSize[2]) {
         case IMAGETYPE_GIF:
             $im = @imageCreateFromGIF($originalPath);
             break;
         case IMAGETYPE_JPEG:
             $im = @imageCreateFromJPEG($originalPath);
             break;
         case IMAGETYPE_PNG:
             $im = @imageCreateFromPNG($originalPath);
             break;
     }
     if ($im) {
         // Better transparency - thanks for the ideas and some code from mediumexposure.com
         if ($imageSize[2] == IMAGETYPE_GIF || $imageSize[2] == IMAGETYPE_PNG) {
             $trnprt_indx = imagecolortransparent($im);
             // If we have a specific transparent color
             if ($trnprt_indx >= 0) {
                 // Get the original image's transparent color's RGB values
                 $trnprt_color = imagecolorsforindex($im, $trnprt_indx);
                 // Allocate the same color in the new image resource
                 $trnprt_indx = imagecolorallocate($image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
                 // Completely fill the background of the new image with allocated color.
                 imagefill($image, 0, 0, $trnprt_indx);
                 // Set the background color for new image to transparent
                 imagecolortransparent($image, $trnprt_indx);
             } else {
                 if ($imageSize[2] == IMAGETYPE_PNG) {
                     // Turn off transparency blending (temporarily)
                     imagealphablending($image, false);
                     // Create a new transparent color for image
                     $color = imagecolorallocatealpha($image, 0, 0, 0, 127);
                     // Completely fill the background of the new image with allocated color.
                     imagefill($image, 0, 0, $color);
                     // Restore transparency blending
                     imagesavealpha($image, true);
                 }
             }
         }
         $res = @imageCopyResampled($image, $im, 0, 0, $crop_src_x, $crop_src_y, $finalWidth, $finalHeight, $oWidth, $oHeight);
         if ($res) {
             switch ($imageSize[2]) {
                 case IMAGETYPE_GIF:
                     $res2 = imageGIF($image, $newPath);
                     break;
                 case IMAGETYPE_JPEG:
                     $compression = defined('AL_THUMBNAIL_JPEG_COMPRESSION') ? AL_THUMBNAIL_JPEG_COMPRESSION : 80;
                     $res2 = imageJPEG($image, $newPath, $compression);
                     break;
                 case IMAGETYPE_PNG:
                     $res2 = imagePNG($image, $newPath);
                     break;
             }
         }
     }
 }
开发者ID:zawzawzaw,项目名称:scoop,代码行数:101,代码来源:image_crop.php


示例5: save

 /**
  * Saves the image to a given filename, if no filename is given then a default is created.
  *
  * @param string $save The new image filename.
  */
 public function save($save = "")
 {
     //save thumb
     if (empty($save)) {
         $save = strtolower("./thumb." . $this->image["outputformat"]);
     } else {
         $this->image["outputformat"] = preg_replace("/.*\\.(.*)\$/", "\\1", $save);
         //$this->image["outputformat"] = preg_replace(".*\.(.*)$", "\\1", $save);
         $this->image["outputformat"] = strtoupper($this->image["outputformat"]);
     }
     $this->createResampledImage();
     if ($this->image["outputformat"] == "JPG" || $this->image["outputformat"] == "JPEG") {
         //JPEG
         imageJPEG($this->image["des"], $save, $this->image["quality"]);
     } elseif ($this->image["outputformat"] == "PNG") {
         //PNG
         imagePNG($this->image["des"], $save, 0);
     } elseif ($this->image["outputformat"] == "GIF") {
         //GIF
         imageGIF($this->image["des"], $save);
     } elseif ($this->image["outputformat"] == "WBMP") {
         //WBMP
         imageWBMP($this->image["des"], $save);
     }
 }
开发者ID:ali-codehoppers,项目名称:adventskalender,代码行数:30,代码来源:ImageManipulation.php


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


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


示例8: imageString

    imageString($im, 5, $dx + $gxb + 2 * $ticW, $i - $labelH, sprintf("%3.1f", $wnd), $blue);
    //}
    $wnd -= $dwnd;
    if ($wnd < 0) {
        $wnd = -$wnd;
    }
}
/* draw the wind direction graph */
$scale = $gyb / 360;
/* wind direction can only go from 0 to 360 degrees */
for ($i = 0; $i + 1 < $row_count; $i++) {
    $x1 = $i * $gxb / $row_count + $dx;
    $y1 = $gyb + $dy - $windd[$i] * $scale;
    $x2 = ($i + 1) * $gxb / $row_count + $dx;
    $y2 = $gyb + $dy - $windd[$i + 1] * $scale;
    imageLine($im, $x1, $y1, $x2, $y2, $red);
}
/* draw the wind speed graph */
$scale = $gyb / ($wnds_max - $wnds_min);
for ($i = 0; $i + 1 < $row_count; $i++) {
    $x1 = $i * $gxb / $row_count + $dx;
    $y1 = $gyb + $dy - ($winds[$i] - $wnds_min) * $scale;
    $x2 = ($i + 1) * $gxb / $row_count + $dx;
    $y2 = $gyb + $dy - ($winds[$i + 1] - $wnds_min) * $scale;
    imageLine($im, $x1, $y1, $x2, $y2, $blue);
}
/* use gif as the image format */
header("Content-type: image/gif");
imageGIF($im);
/* lastly delete the image from memory */
imageDestroy($im);
开发者ID:BackupTheBerlios,项目名称:wth-svn,代码行数:31,代码来源:wind.gif.php


示例9: createNewImage

 private function createNewImage($newImg, $newName, $imgInfo)
 {
     $this->path = rtrim($this->path, "/") . "/";
     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
             $result = imagePng($newImg, $this->path . $newName);
             break;
     }
     imagedestroy($newImg);
     return $newName;
 }
开发者ID:mikelkl,项目名称:online_exam,代码行数:20,代码来源:image.class.php


示例10: create

 /**
  * Creates a new image given an original path, a new path, a target width and height.
  * @params string $originalPath, string $newpath, int $width, int $height
  * @return void
  */
 public function create($originalPath, $newPath, $width, $height)
 {
     // first, we grab the original image. We shouldn't ever get to this function unless the image is valid
     $imageSize = @getimagesize($originalPath);
     $oWidth = $imageSize[0];
     $oHeight = $imageSize[1];
     $finalWidth = 0;
     $finalHeight = 0;
     // first, if what we're uploading is actually smaller than width and height, we do nothing
     if ($oWidth < $width && $oHeight < $height) {
         $finalWidth = $oWidth;
         $finalHeight = $oHeight;
     } else {
         // otherwise, we do some complicated stuff
         // first, we divide original width and height by new width and height, and find which difference is greater
         $wDiff = $oWidth / $width;
         $hDiff = $oHeight / $height;
         if ($wDiff > $hDiff) {
             // there's more of a difference between width than height, so if we constrain to width, we should be safe
             $finalWidth = $width;
             $finalHeight = $oHeight / ($oWidth / $width);
         } else {
             // more of a difference in height, so we do the opposite
             $finalWidth = $oWidth / ($oHeight / $height);
             $finalHeight = $height;
         }
     }
     $image = @imageCreateTrueColor($finalWidth, $finalHeight);
     switch ($imageSize[2]) {
         case IMAGETYPE_GIF:
             $im = @imageCreateFromGIF($originalPath);
             break;
         case IMAGETYPE_JPEG:
             $im = @imageCreateFromJPEG($originalPath);
             break;
         case IMAGETYPE_PNG:
             $im = @imageCreateFromPNG($originalPath);
             break;
     }
     if ($im) {
         // Better transparency - thanks for the ideas and some code from mediumexposure.com
         if ($imageSize[2] == IMAGETYPE_GIF || $imageSize[2] == IMAGETYPE_PNG) {
             $trnprt_indx = imagecolortransparent($im);
             // If we have a specific transparent color
             if ($trnprt_indx >= 0) {
                 // Get the original image's transparent color's RGB values
                 $trnprt_color = imagecolorsforindex($im, $trnprt_indx);
                 // Allocate the same color in the new image resource
                 $trnprt_indx = imagecolorallocate($image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
                 // Completely fill the background of the new image with allocated color.
                 imagefill($image, 0, 0, $trnprt_indx);
                 // Set the background color for new image to transparent
                 imagecolortransparent($image, $trnprt_indx);
             } else {
                 if ($imageSize[2] == IMAGETYPE_PNG) {
                     // Turn off transparency blending (temporarily)
                     imagealphablending($image, false);
                     // Create a new transparent color for image
                     $color = imagecolorallocatealpha($image, 0, 0, 0, 127);
                     // Completely fill the background of the new image with allocated color.
                     imagefill($image, 0, 0, $color);
                     // Restore transparency blending
                     imagesavealpha($image, true);
                 }
             }
         }
         $res = @imageCopyResampled($image, $im, 0, 0, 0, 0, $finalWidth, $finalHeight, $oWidth, $oHeight);
         if ($res) {
             switch ($imageSize[2]) {
                 case IMAGETYPE_GIF:
                     $res2 = imageGIF($image, $newPath);
                     break;
                 case IMAGETYPE_JPEG:
                     $res2 = imageJPEG($image, $newPath, AL_THUMBNAIL_JPEG_COMPRESSION);
                     break;
                 case IMAGETYPE_PNG:
                     $res2 = imagePNG($image, $newPath);
                     break;
             }
         }
     }
 }
开发者ID:homer6,项目名称:concrete5-mirror,代码行数:87,代码来源:image.php


示例11: create


//.........这里部分代码省略.........
                 }
             } else {
                 $image->setSize($width, $height);
                 if ($image->readImage($originalPath) === true) {
                     $image->thumbnailImage($finalWidth, $finalHeight);
                     $imageRead = true;
                 }
             }
             if ($imageRead) {
                 if ($image->getCompression() == imagick::COMPRESSION_JPEG) {
                     $image->setCompressionQuality($this->jpegCompression);
                 }
                 if ($image->writeImage($newPath) === true) {
                     $processed = true;
                 }
             }
         } catch (Exception $x) {
         }
     }
     if (!$processed) {
         //create "canvas" to put new resized and/or cropped image into
         if ($crop) {
             $image = @imageCreateTrueColor($width, $height);
         } else {
             $image = @imageCreateTrueColor($finalWidth, $finalHeight);
         }
         if ($image === false) {
             return false;
         }
         $im = false;
         switch ($imageSize[2]) {
             case IMAGETYPE_GIF:
                 $im = @imageCreateFromGIF($originalPath);
                 break;
             case IMAGETYPE_JPEG:
                 $im = @imageCreateFromJPEG($originalPath);
                 break;
             case IMAGETYPE_PNG:
                 $im = @imageCreateFromPNG($originalPath);
                 break;
             default:
                 @imagedestroy($image);
                 return false;
         }
         if ($im === false) {
             @imagedestroy($image);
             return false;
         }
         // Better transparency - thanks for the ideas and some code from mediumexposure.com
         if ($imageSize[2] == IMAGETYPE_GIF || $imageSize[2] == IMAGETYPE_PNG) {
             $trnprt_indx = imagecolortransparent($im);
             // If we have a specific transparent color
             if ($trnprt_indx >= 0 && $trnprt_indx < imagecolorstotal($im)) {
                 // Get the original image's transparent color's RGB values
                 $trnprt_color = imagecolorsforindex($im, $trnprt_indx);
                 // Allocate the same color in the new image resource
                 $trnprt_indx = imagecolorallocate($image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
                 // Completely fill the background of the new image with allocated color.
                 imagefill($image, 0, 0, $trnprt_indx);
                 // Set the background color for new image to transparent
                 imagecolortransparent($image, $trnprt_indx);
             } else {
                 if ($imageSize[2] == IMAGETYPE_PNG) {
                     // Turn off transparency blending (temporarily)
                     imagealphablending($image, false);
                     // Create a new transparent color for image
                     $color = imagecolorallocatealpha($image, 0, 0, 0, 127);
                     // Completely fill the background of the new image with allocated color.
                     imagefill($image, 0, 0, $color);
                     // Restore transparency blending
                     imagesavealpha($image, true);
                 }
             }
         }
         $res = @imageCopyResampled($image, $im, 0, 0, $crop_src_x, $crop_src_y, $finalWidth, $finalHeight, $oWidth, $oHeight);
         @imagedestroy($im);
         if ($res === false) {
             @imagedestroy($image);
             return false;
         }
         $res2 = false;
         switch ($imageSize[2]) {
             case IMAGETYPE_GIF:
                 $res2 = @imageGIF($image, $newPath);
                 break;
             case IMAGETYPE_JPEG:
                 $res2 = @imageJPEG($image, $newPath, $this->jpegCompression);
                 break;
             case IMAGETYPE_PNG:
                 $res2 = @imagePNG($image, $newPath);
                 break;
         }
         @imagedestroy($image);
         if ($res2 === false) {
             return false;
         }
     }
     @chmod($newPath, FILE_PERMISSIONS_MODE);
     return true;
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:101,代码来源:image.php


示例12: generateImage

 function generateImage($save = '', $show = true)
 {
     if ($this->img['format'] == 'GIF' && !$this->gifsupport) {
         // --- kein caching -> gif ausgeben
         $this->send();
     }
     $this->resampleImage();
     $this->applyFilters();
     if ($this->img['format'] == 'JPG' || $this->img['format'] == 'JPEG') {
         imageJPEG($this->img['des'], $save, $this->img['quality']);
     } elseif ($this->img['format'] == 'PNG') {
         imagePNG($this->img['des'], $save);
     } elseif ($this->img['format'] == 'GIF') {
         imageGIF($this->img['des'], $save);
     } elseif ($this->img['format'] == 'WBMP') {
         imageWBMP($this->img['des'], $save);
     }
     if ($show) {
         $this->send($save);
     }
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:21,代码来源:class.thumbnail.inc.php


示例13: show

 function show()
 {
     if ($this->img['format'] == "JPG" || $this->img['format'] == "JPEG") {
         //JPEG
         imageJPEG($this->img['src'], "", $this->img['quality']);
     } elseif ($this->img['format'] == "PNG") {
         //PNG
         imagePNG($this->img['src']);
     } elseif ($this->img['format'] == "GIF") {
         //GIF
         imageGIF($this->img['src']);
     }
     imagedestroy($this->img['src']);
 }
开发者ID:dautushenka,项目名称:car-market,代码行数:14,代码来源:thumb.class.php


示例14: generateThumbnail

 function generateThumbnail($w, $h, $dstPath)
 {
     $cw = $this->width();
     $ch = $this->height();
     $format = $this->format();
     $image = $this->image();
     if ($cw > $w) {
         $new_width = $w;
         $new_height = round($ch * ($new_width * 100 / $cw) / 100);
         if ($new_height > $h) {
             $new_height_before = $new_height;
             $new_height = $h;
             $new_width = round($new_width * ($new_height * 100 / $new_height_before) / 100);
         }
     } else {
         if ($ch > $h) {
             $new_height = $h;
             $new_width = round($cw * ($new_height * 100 / $ch) / 100);
             if ($new_width > $w) {
                 $new_width_before = $new_width;
                 $new_width = $w;
                 $new_height = round($new_height * ($new_width * 100 / $new_width_before) / 100);
             }
         } else {
             $new_width = $w;
             $new_height = round($ch * ($new_width * 100 / $cw) / 100);
             if ($new_height > $h) {
                 $new_height_before = $new_height;
                 $new_height = $h;
                 $new_width = round($new_width * ($new_height * 100 / $new_height_before) / 100);
             }
         }
     }
     if (function_exists('ImageCreateTrueColor')) {
         $new_image = ImageCreateTrueColor($new_width, $new_height);
     } else {
         $new_image = ImageCreate($new_width, $new_height);
     }
     if (function_exists('imagecopyresampled')) {
         if ($format == 'png' || $format == 'gif') {
             imagecolortransparent($new_image, imagecolorallocatealpha($new_image, 0, 0, 0, 127));
         } else {
             imagecolortransparent($new_image, imagecolorallocate($new_image, 0, 0, 0));
         }
         imagealphablending($new_image, false);
         imagesavealpha($new_image, true);
         @imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $cw, $ch);
     } else {
         @imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $cw, $ch);
     }
     switch ($format) {
         case 'jpg':
             imageJPEG($new_image, $dstPath, 750);
             break;
         case 'png':
             imagePNG($new_image, $dstPath);
             break;
         case 'gif':
             imageGIF($new_image, $dstPath);
             break;
         default:
             throw new Exception('Unknown image format');
             break;
     }
 }
开发者ID:jagermesh,项目名称:bright,代码行数:65,代码来源:BrImage.php


示例15: _output

 protected function _output($method, $format, $filename)
 {
     switch ($format) {
         case parent::FORMAT_GIF:
             if ($method == parent::OUTPUT_INLINE || $method == parent::OUTPUT_DOWNLOAD) {
                 return imageGIF($this->canvas);
             } else {
                 if ($method == parent::OUTPUT_SAVE) {
                     return imageGIF($this->canvas, $filename);
                 }
             }
             break;
         case parent::FORMAT_JPEG:
             if ($method == parent::OUTPUT_INLINE || $method == parent::OUTPUT_DOWNLOAD) {
                 return imageJPEG($this->canvas, NULL, $this->quality);
             } else {
                 if ($method == parent::OUTPUT_SAVE) {
                     return imageJPEG($this->canvas, $filename, $this->quality);
                 }
             }
             break;
         case parent::FORMAT_PNG:
             if ($method == parent::OUTPUT_INLINE || $method == parent::OUTPUT_DOWNLOAD) {
                 return imagePNG($this->canvas);
             } else {
                 if ($method == parent::OUTPUT_SAVE) {
                     return imagePNG($this->canvas, $filename);
                 }
             }
             break;
     }
     return false;
     // The output method or format is missing!
 }
开发者ID:samchristy,项目名称:piechart,代码行数:34,代码来源:PieChartGD.php


示例16: edit

	public function edit($path, $crop_x, $crop_y, $crop_w, $crop_h, $target_w, $target_h) {
		$imageSize = @getimagesize($path);
		$img_type = $imageSize[2];
		
		//create "canvas" to put new resized and/or cropped image into
		$image = @imageCreateTrueColor($target_w, $target_h);
		
		switch($img_type) {
			case IMAGETYPE_GIF:
				$im = @imageCreateFromGIF($path);
				break;
			case IMAGETYPE_JPEG:
				$im = @imageCreateFromJPEG($path);
				break;
			case IMAGETYPE_PNG:
				$im = @imageCreateFromPNG($path);
				break;
		}
		
		if ($im) {
			// Better transparency - thanks for the ideas and some code from mediumexposure.com
			if (($img_type == IMAGETYPE_GIF) || ($img_type == IMAGETYPE_PNG)) {
				$trnprt_indx = imagecolortransparent($im);
				
				// If we have a specific transparent color
				if ($trnprt_indx >= 0) {
			
					// Get the original image's transparent color's RGB values
					$trnprt_color = imagecolorsforindex($im, $trnprt_indx);
					
					// Allocate the same color in the new image resource
					$trnprt_indx = imagecolorallocate($image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
					
					// Completely fill the background of the new image with allocated color.
					imagefill($image, 0, 0, $trnprt_indx);
					
					// Set the background color for new image to transparent
					imagecolortransparent($image, $trnprt_indx);
					
				
				} else if ($img_type == IMAGETYPE_PNG) {
				
					// Turn off transparency blending (temporarily)
					imagealphablending($image, false);
					
					// Create a new transparent color for image
					$color = imagecolorallocatealpha($image, 0, 0, 0, 127);
					
					// Completely fill the background of the new image with allocated color.
					imagefill($image, 0, 0, $color);
					
					// Restore transparency blending
					imagesavealpha($image, true);
			
				}
			}
			
			$res = @imageCopyResampled($image, $im, 0, 0, $crop_x, $crop_y, $target_w, $target_h, $crop_w, $crop_h);
			if ($res) {
				switch($img_type) {
					case IMAGETYPE_GIF:
						$res2 = imageGIF($image, $path);
						break;
					case IMAGETYPE_JPEG:
						$compression = defined('AL_THUMBNAIL_JPEG_COMPRESSION') ? AL_THUMBNAIL_JPEG_COMPRESSION : 80;
						$res2 = imageJPEG($image, $path, $compression);
						break;
					case IMAGETYPE_PNG:
						$res2 = imagePNG($image, $path);
						break;
				}
			}
		}
	}
开发者ID:netconstructor,项目名称:c5_image_cropper,代码行数:74,代码来源:image_cropper.php


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


示例18: create


//.........这里部分代码省略.........
             $newHeight = $originalHeight;
             $cropWidth = true;
             $cropHeight = false;
         } else {
             if ($newWidth >= $originalWidth && $newHeight <= $originalHeight) {
                 //crop to height only -- don't scale anything
                 $scaleToHeight = $originalHeight;
                 $scaleToWidth = $originalWidth;
                 $newWidth = $originalWidth;
                 $cropWidth = false;
                 $cropHeight = true;
             } else {
                 //Scale down until we hit one of the new dimensions, then crop the other dimension.
                 $widthRatio = $originalWidth / $newWidth;
                 $heightRatio = $originalHeight / $newHeight;
                 if ($widthRatio < $heightRatio) {
                     //we'll scale to width's proportion, then crop height to target
                     $scaleToWidth = $newWidth;
                     $scaleToHeight = $originalHeight / $widthRatio;
                     $cropWidth = false;
                     $cropHeight = true;
                 } else {
                     //we'll scale to height's proportion, then crop width to target
                     $scaleToWidth = $originalWidth / $heightRatio;
                     $scaleToHeight = $newHeight;
                     $cropWidth = true;
                     $cropHeight = false;
                 }
             }
         }
     }
     $newImage = @imageCreateTrueColor($newWidth, $newHeight);
     $imageType = $originalImageData[2];
     switch ($imageType) {
         case IMAGETYPE_GIF:
             $im = @imageCreateFromGIF($originalPath);
             break;
         case IMAGETYPE_JPEG:
             $im = @imageCreateFromJPEG($originalPath);
             break;
         case IMAGETYPE_PNG:
             $im = @imageCreateFromPNG($originalPath);
             break;
     }
     if ($im) {
         // Better transparency - thanks for the ideas and some code from mediumexposure.com
         if ($imageType == IMAGETYPE_GIF || $imageType == IMAGETYPE_PNG) {
             $trnprt_indx = imagecolortransparent($im);
             // If we have a specific transparent color
             if ($trnprt_indx >= 0) {
                 // Get the original image's transparent color's RGB values
                 $trnprt_color = imagecolorsforindex($im, $trnprt_indx);
                 // Allocate the same color in the new image resource
                 $trnprt_indx = imagecolorallocate($newImage, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
                 // Completely fill the background of the new image with allocated color.
                 imagefill($newImage, 0, 0, $trnprt_indx);
                 // Set the background color for new image to transparent
                 imagecolortransparent($newImage, $trnprt_indx);
             } else {
                 if ($imageType == IMAGETYPE_PNG) {
                     // Turn off transparency blending (temporarily)
                     imagealphablending($newImage, false);
                     // Create a new transparent color for image
                     $color = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
                     // Completely fill the background of the new image with allocated color.
                     imagefill($newImage, 0, 0, $color);
                     // Restore transparency blending
                     imagesavealpha($newImage, true);
                 }
             }
         }
   

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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