本文整理汇总了PHP中imageJpeg函数的典型用法代码示例。如果您正苦于以下问题:PHP imageJpeg函数的具体用法?PHP imageJpeg怎么用?PHP imageJpeg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageJpeg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: save
/**
* 生成された画像を保存する
*
* @return boolean
* @access public
* @static
*/
function save()
{
//保存先のディレクトリが存在しているかチェック
$filePath = dirname($this->dstPath);
if (!file_exists($filePath)) {
mkdir($filePath);
}
if ($this->imageType == 'image/jpeg') {
return imageJpeg($this->dstImage, $this->dstPath, $this->quality);
} elseif ($this->imageType == 'image/gif') {
return imageGif($this->dstImage, $this->dstPath);
} elseif ($this->imageType == 'image/png') {
return imagePng($this->dstImage, $this->dstPath);
}
}
开发者ID:hamhei,项目名称:onatter,代码行数:22,代码来源:thumbmake.php
示例2: resize_image
public function resize_image($data, $imgX, $sizedef, $lid, $imgid)
{
$file = $data["raw_name"];
$type = $data["file_ext"];
$outfile = $imgX[$sizedef]['dir'] . "/" . $lid . "/" . $file . '.jpg';
$path = $this->config->item("upload_dir");
$image = $this->create_image_container($file, $type);
if ($image) {
$size = GetImageSize($path . $file . $type);
$old = $image;
// сей форк - не просто так. непонятно, правда, почему...
if ($size['1'] < $size['0']) {
$h_new = round($imgX[$sizedef]['max_dim'] * ($size['1'] / $size['0']));
$measures = array($imgX[$sizedef]['max_dim'], $h_new);
}
if ($size['1'] >= $size['0']) {
$h_new = round($imgX[$sizedef]['max_dim'] * ($size['0'] / $size['1']));
$measures = array($h_new, $imgX[$sizedef]['max_dim']);
}
$new = ImageCreateTrueColor($measures[0], $measures[1]);
ImageCopyResampled($new, $image, 0, 0, 0, 0, $measures[0], $measures[1], $size['0'], $size['1']);
imageJpeg($new, $outfile, $imgX[$sizedef]['quality']);
$this->db->query("UPDATE `images` SET `images`.`" . $sizedef . "` = ? WHERE `images`.`id` = ?", array(implode($measures, ","), $imgid));
imageDestroy($new);
}
}
开发者ID:korzhevdp,项目名称:MiniGIS,代码行数:26,代码来源:uploadmodel.php
示例3: image_createThumb
function image_createThumb($src, $dest, $maxWidth, $maxHeight, $quality = 75)
{
if (file_exists($src) && isset($dest)) {
// path info
$destInfo = pathInfo($dest);
// image src size
$srcSize = getImageSize($src);
// image dest size $destSize[0] = width, $destSize[1] = height
$srcRatio = $srcSize[0] / $srcSize[1];
// width/height ratio
$destRatio = $maxWidth / $maxHeight;
if ($destRatio > $srcRatio) {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight * $srcRatio;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth / $srcRatio;
}
// path rectification
if ($destInfo['extension'] == "gif") {
$dest = substr_replace($dest, 'jpg', -3);
}
// true color image, with anti-aliasing
$destImage = imageCreateTrueColor($destSize[0], $destSize[1]);
// imageAntiAlias($destImage,true);
// src image
switch ($srcSize[2]) {
case 1:
//GIF
$srcImage = imageCreateFromGif($src);
break;
case 2:
//JPEG
$srcImage = imageCreateFromJpeg($src);
break;
case 3:
//PNG
$srcImage = imageCreateFromPng($src);
break;
default:
return false;
break;
}
// resampling
imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destSize[0], $destSize[1], $srcSize[0], $srcSize[1]);
// generating image
switch ($srcSize[2]) {
case 1:
case 2:
imageJpeg($destImage, $dest, $quality);
break;
case 3:
imagePng($destImage, $dest);
break;
}
return true;
} else {
return 'No such File';
}
}
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:60,代码来源:resize.php
示例4: resizeImage
private function resizeImage($file, $data, $tmd = 600, $quality = 100)
{
$data['type'] = "image/jpeg";
$basename = basename($file);
$filesDir = $this->input->post('uploadDir');
// хэш нередактируемой карты!
$uploaddir = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', $tmd, $filesDir), DIRECTORY_SEPARATOR);
$srcFile = implode(array($this->input->server('DOCUMENT_ROOT'), 'storage', 'source', $filesDir, $basename), DIRECTORY_SEPARATOR);
$image = $this->createimageByType($data, $srcFile);
if (!file_exists($uploaddir)) {
mkdir($uploaddir, 0775, true);
}
$size = GetImageSize($srcFile);
$new = ImageCreateTrueColor($size['1'], $size['0']);
if ($size['1'] > $tmd || $size['0'] > $tmd) {
if ($size['1'] < $size['0']) {
$hNew = round($tmd * $size['1'] / $size['0']);
$new = ImageCreateTrueColor($tmd, $hNew);
ImageCopyResampled($new, $image, 0, 0, 0, 0, $tmd, $hNew, $size['0'], $size['1']);
}
if ($size['1'] >= $size['0']) {
$hNew = round($tmd * $size['0'] / $size['1']);
$new = ImageCreateTrueColor($hNew, $tmd);
ImageCopyResampled($new, $image, 0, 0, 0, 0, $hNew, $tmd, $size['0'], $size['1']);
}
}
//print $uploaddir."/".TMD."/".$filename.".jpg<br>";
imageJpeg($new, $uploaddir . DIRECTORY_SEPARATOR . $basename, $quality);
//header("content-type: image/jpeg");// активировать для отладки
//imageJpeg ($new, "", 100);//активировать для отладки
imageDestroy($new);
}
开发者ID:korzhevdp,项目名称:freehand,代码行数:32,代码来源:upload.php
示例5: generate_thumbnail
function generate_thumbnail($file, $mime)
{
global $config;
gd_capabilities();
list($file_type, $exact_type) = explode("/", $mime);
if (_JB_GD_INSTALLED && ($file_type = "image")) {
if ($exact_type != "gif" && $exact_type != "png" && $exact_type != "jpeg") {
return false;
}
if ($exact_type == "gif" && !_JB_GD_GIF) {
return false;
}
if ($exact_type == "png" && !_JB_GD_PNG) {
return false;
}
if ($exact_type == "jpeg" && !_JB_GD_JPG) {
return false;
}
// Load up the original and get size
// NOTE: use imageCreateFromString to avoid to have to check what type of image it is
$original = imageCreateFromString(file_get_contents($file));
$original_w = imagesX($original);
$original_h = imagesY($original);
// Only if the image is really too big, resize it
// NOTE: if image is smaller than target size, don't do anything.
// We *could* copy the original to filename_thumb, but since it's the same
// it would be a waste of precious resources
if ($original_w > $config['uploader']['thumb_w'] || $original_h > $config['uploader']['thumb_h']) {
// If original is wider than it's high, resize the width and vice versa
// NOTE: '>=' cause otherwise it's possible that $scale isn't computed
if ($original_w >= $original_h) {
$scaled_w = $config['uploader']['thumb_w'];
// Figure out how much smaller that target is than original
// and apply it to height
$scale = $config['uploader']['thumb_w'] / $original_w;
$scaled_h = ceil($original_h * $scale);
} elseif ($original_w <= $original_h) {
$scaled_h = $config['uploader']['thumb_h'];
$scale = $config['uploader']['thumb_h'] / $original_h;
$scaled_w = ceil($original_w * $scale);
}
} else {
// Break out of if($file_type = image) since no resize is possible
return false;
}
// Scale the image
$scaled = imageCreateTrueColor($scaled_w, $scaled_h);
imageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
// Store thumbs in jpeg, hope no one minds the 100% quality lol
imageJpeg($scaled, $file . "_thumb", 100);
// Let's be nice to our server
imagedestroy($scaled);
imagedestroy($original);
return true;
}
}
开发者ID:victorjacobs,项目名称:jetbird,代码行数:56,代码来源:image.functions.php
示例6: writeCopy
function writeCopy($filename, $width, $height) {
if($this->isLoaded()) {
$imageNew = imageCreate($width, $height);
if(!$imageNew) {
echo "ERREUR : Nouvelle image non créée";
}
imageCopyResized($imageNew, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
imageJpeg($imageNew, $filename);
}
}
开发者ID:nidtropical,项目名称:nidtropical_old,代码行数:10,代码来源:index.php
示例7: saveFile
public static function saveFile($image = null, $destFile = null, $saveType = self::SAVE_JPG)
{
switch ($saveType) {
case self::SAVE_GIF:
return @imageGif($image, $destFile);
case self::SAVE_JPG:
return @imageJpeg($image, $destFile, self::SAVE_QUALITY);
case self::SAVE_PNG:
return @imagePng($image, $destFile);
default:
return false;
}
}
开发者ID:yunsite,项目名称:hhzuitu,代码行数:13,代码来源:Image.class.php
示例8: createTestImage
/**
* Create test image.
*
* @param string $filename
* @return void
*/
protected function createTestImage($filename)
{
$filename = $this->getFullPath($filename);
if (!file_exists($filename)) {
// Create an image with the specified dimensions
$image = imageCreate(300, 200);
// Create a color (this first call to imageColorAllocate
// also automatically sets the image background color)
$colorYellow = imageColorAllocate($image, 255, 255, 0);
// Draw a rectangle
imageFilledRectangle($image, 50, 50, 250, 150, $colorYellow);
$directory = dirname($filename);
if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
imageJpeg($image, $filename);
// Release memory
imageDestroy($image);
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:MediaGallery.php
示例9: make_img
function make_img($content)
{
$timage = array(strlen($content) * 20 + 10, 28);
// array(largeur, hauteur) de l'image; ici la largeur est fonction du nombre de lettre du contenu, on peut bien sur mettre une largeur fixe.
$content = preg_replace('/(\\w)/', '\\1 ', $content);
// laisse plus d'espace entre les lettres
$image = imagecreatetruecolor($timage[0], $timage[1]);
// création de l'image
// definition des couleurs
$fond = imageColorAllocate($image, 240, 255, 240);
$grey = imageColorAllocate($image, 210, 210, 210);
$text_color = imageColorAllocate($image, rand(0, 100), rand(0, 50), rand(0, 60));
imageFill($image, 0, 0, $fond);
// on remplit l'image de blanc
//On remplit l'image avec des polygones
for ($i = 0, $imax = mt_rand(3, 5); $i < $imax; $i++) {
$x = mt_rand(3, 10);
$poly = array();
for ($j = 0; $j < $x; $j++) {
$poly[] = mt_rand(0, $timage[0]);
$poly[] = mt_rand(0, $timage[1]);
}
imageFilledPolygon($image, $poly, $x, imageColorAllocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
}
// Création des pixels gris
for ($i = 0; $i < $timage[0] * $timage[1] / rand(15, 18); $i++) {
imageSetPixel($image, rand(0, $timage[0]), rand(0, $timage[1]), $grey);
}
// affichage du texte demandé; on le centre en hauteur et largeur (à peu près ^^")
//imageString($image, 5, ceil($timage[0]-strlen($content)*8)/2, ceil($timage[1]/2)-9, $content, $text_color);
$longueur_chaine = strlen($content);
for ($ch = 0; $ch < $longueur_chaine; $ch++) {
imagettftext($image, 18, mt_rand(-30, 30), 10 * ($ch + 1), mt_rand(18, 20), $text_color, 'res/georgia.ttf', $content[$ch]);
}
$type = function_exists('imageJpeg') ? 'jpeg' : 'png';
@header('Content-Type: image/' . $type);
@header('Cache-control: no-cache, no-store');
$type == 'png' ? imagePng($image) : imageJpeg($image);
ImageDestroy($image);
exit;
}
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:41,代码来源:captcha.php
示例10: resizeImage
function resizeImage($file, $max_x, $max_y, $forcePng = false)
{
if ($max_x <= 0 || $max_y <= 0) {
$max_x = 5;
$max_y = 5;
}
$src = BASEDIR . '/avatars/' . $file;
list($width, $height, $type) = getImageSize($src);
$scale = min($max_x / $width, $max_y / $height);
$newWidth = $width * $scale;
$newHeight = $height * $scale;
$img = imagecreatefromstring(file_get_contents($src));
$black = imagecolorallocate($img, 0, 0, 0);
$resizedImage = imageCreateTrueColor($newWidth, $newHeight);
imagecolortransparent($resizedImage, $black);
imageCopyResampled($resizedImage, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
imageDestroy($img);
unlink($src);
if (!$forcePng) {
switch ($type) {
case IMAGETYPE_JPEG:
imageJpeg($resizedImage, BASEDIR . '/avatars/' . $file);
break;
case IMAGETYPE_GIF:
imageGif($resizedImage, BASEDIR . '/avatars/' . $file);
break;
case IMAGETYPE_PNG:
imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
break;
default:
imagePng($resizedImage, BASEDIR . '/avatars/' . $file);
break;
}
} else {
imagePng($resizedImage, BASEDIR . '/avatars/' . $file . '.png');
}
return;
}
开发者ID:kandran,项目名称:flyspray,代码行数:38,代码来源:modify.inc.php
示例11: save
function save($filename, $type = 'png', $quality = 100)
{
$this->_build();
$this->_build_border();
switch ($type) {
case 'gif':
$ret = imageGif($this->_dest_image, $filename);
break;
case 'jpg':
case 'jpeg':
$ret = imageJpeg($this->_dest_image, $filename, $quality);
break;
case 'png':
$ret = imagePng($this->_dest_image, $filename);
break;
default:
$this->_error('Save: Invalid Format');
break;
}
if (!$ret) {
$this->_error('Save: Unable to save');
}
}
开发者ID:mbassan,项目名称:backstage2,代码行数:23,代码来源:Image.php
示例12: resizeJpeg
private function resizeJpeg($newW, $newH, $oWidth, $oHeight, $fullPath)
{
// create a new canvas
$im = ImageCreateTruecolor($newW, $newH);
$baseImage = ImageCreateFromJpeg($this->imageName);
// if successful this returns as true - this is the actual resizing
if (imagecopyresampled($im, $baseImage, 0, 0, 0, 0, $newW, $newH, $oWidth, $oHeight)) {
// resizing is successful and saved to $fullPath
imageJpeg($im, $fullPath);
if (file_exists($fullPath)) {
$this->msg .= 'Resized file created<br />';
imagedestroy($im);
// don't really need this cos $im will disappear after function done
return true;
} else {
$this->msg .= 'Failure in resize jpeg<br />';
}
} else {
// resizing fails
$this->msg .= 'Unable to resize image<br />';
return false;
}
}
开发者ID:Juterpillar,项目名称:artprints,代码行数:23,代码来源:resizeImageClass.php
示例13: createThumbMobile
function createThumbMobile($src, $dest, $desired_width)
{
$max_h = 68;
$max_w = 80;
if ($max_w > $max_h) {
$max_h = $max_w;
} else {
if ($max_h > $max_w) {
$max_w = $max_h;
}
}
$size = getImageSize($src);
$old_w = $size[0];
$old_h = $size[1];
if ($old_w > $old_h) {
$nw = $max_w;
$nh = $old_h * ($max_w / $old_w);
}
if ($old_w < $old_h) {
$nw = $old_w * ($max_h / $old_h);
$nh = $max_h;
}
if ($old_w == $old_h) {
$nw = $max_w;
$nh = $max_h;
}
// Building the intermediate resized thumbnail
$resimage = imagecreatefromjpeg($src);
$newimage = imagecreatetruecolor($nw, $nh);
// use alternate function if not installed
imageCopyResampled($newimage, $resimage, 0, 0, 0, 0, $nw, $nh, $old_w, $old_h);
// Making the final cropped thumbnail
$viewimage = imagecreatetruecolor($max_w, $max_h);
$bg = imagecolorallocate($viewimage, 255, 255, 255);
imagefill($viewimage, 0, 0, $bg);
imagecopy($viewimage, $newimage, 0, 0, 0, 0, $nw, $nh);
// saving
imageJpeg($viewimage, $dest, 85);
}
开发者ID:keyanmca,项目名称:yoga,代码行数:39,代码来源:AdminController.php
示例14: Main
//.........这里部分代码省略.........
// サイズが同じ場合には、そのままコピーする。(画質劣化を防ぐ)
copy($path, $dst_file);
} else {
imagepng($dst_im, $dst_file);
}
}
imagedestroy($src_im);
imagedestroy($dst_im);
}
} else {
// サムネイル作成不可の場合(旧バージョン対策)
$dst_im = imageCreate($re_size[0], $re_size[1]);
imageColorAllocate($dst_im, 255, 255, 214);
//背景色
// 枠線と文字色の設定
$black = imageColorAllocate($dst_im, 0, 0, 0);
$red = imageColorAllocate($dst_im, 255, 0, 0);
imagestring($dst_im, 5, 10, 10, "GIF {$size['0']}x{$size['1']}", $red);
imageRectangle($dst_im, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black);
// 画像出力
if ($header) {
header("Content-Type: image/png");
imagepng($dst_im);
return "";
} else {
$dst_file = $dst_file . ".png";
imagepng($dst_im, $dst_file);
}
imagedestroy($src_im);
imagedestroy($dst_im);
}
break;
// jpg形式
// jpg形式
case "2":
$src_im = imageCreateFromJpeg($path);
$dst_im = $imagecreate($re_size[0], $re_size[1]);
$imageresize($dst_im, $src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
// 画像出力
if ($header) {
header("Content-Type: image/jpeg");
imageJpeg($dst_im);
return "";
} else {
$dst_file = $dst_file . ".jpg";
if ($re_size[0] == $size[0] && $re_size[1] == $size[1]) {
// サイズが同じ場合には、そのままコピーする。(画質劣化を防ぐ)
copy($path, $dst_file);
} else {
imageJpeg($dst_im, $dst_file);
}
}
imagedestroy($src_im);
imagedestroy($dst_im);
break;
// png形式
// png形式
case "3":
$src_im = imageCreateFromPNG($path);
$colortransparent = imagecolortransparent($src_im);
$has_alpha = ord(file_get_contents($path, false, null, 25, 1)) & 0x4;
if ($colortransparent > -1 || $has_alpha) {
$dst_im = $imagecreate($re_size[0], $re_size[1]);
// アルファチャンネルが存在する場合はそちらを使用する
if ($has_alpha) {
imagealphablending($dst_im, false);
imagesavealpha($dst_im, true);
}
imagepalettecopy($dst_im, $src_im);
imagefill($dst_im, 0, 0, $colortransparent);
imagecolortransparent($dst_im, $colortransparent);
imagecopyresized($dst_im, $src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
} else {
$dst_im = $imagecreate($re_size[0], $re_size[1]);
imagecopyresized($dst_im, $src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
imagecolorstotal($src_im) == 0 ? $colortotal = 65536 : ($colortotal = imagecolorstotal($src_im));
imagetruecolortopalette($dst_im, true, $colortotal);
}
// 画像出力
if ($header) {
header("Content-Type: image/png");
imagepng($dst_im);
return "";
} else {
$dst_file = $dst_file . ".png";
if ($re_size[0] == $size[0] && $re_size[1] == $size[1]) {
// サイズが同じ場合には、そのままコピーする。(画質劣化を防ぐ)
copy($path, $dst_file);
} else {
imagepng($dst_im, $dst_file);
}
}
imagedestroy($src_im);
imagedestroy($dst_im);
break;
default:
return array(0, "イメージの形式が不明です。");
}
return array(1, $dst_file);
}
开发者ID:casan,项目名称:eccube-2_13,代码行数:101,代码来源:gdthumb.php
示例15: ImageWrite
/**
* Writes the input GDlib image pointer to file
*
* @param resource $destImg The GDlib image resource pointer
* @param string $theImage The filename to write to
* @param int $quality The image quality (for JPEGs)
* @return bool The output of either imageGif, imagePng or imageJpeg based on the filename to write
* @see maskImageOntoImage(), scale(), output()
*/
public function ImageWrite($destImg, $theImage, $quality = 0)
{
imageinterlace($destImg, 0);
$ext = strtolower(substr($theImage, strrpos($theImage, '.') + 1));
$result = false;
switch ($ext) {
case 'jpg':
case 'jpeg':
if (function_exists('imageJpeg')) {
if ($quality == 0) {
$quality = $this->jpegQuality;
}
$result = imageJpeg($destImg, $theImage, $quality);
}
break;
case 'gif':
if (function_exists('imageGif')) {
imagetruecolortopalette($destImg, true, 256);
$result = imageGif($destImg, $theImage);
}
break;
case 'png':
if (function_exists('imagePng')) {
$result = ImagePng($destImg, $theImage);
}
break;
}
if ($result) {
GeneralUtility::fixPermissions($theImage);
}
return $result;
}
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:41,代码来源:GraphicalFunctions.php
示例16: imagecreatefromgif
// readfile($filename);
// exit;
$old_image = imagecreatefromgif($filename);
} elseif ($image_format == 2) {
$old_image = imagecreatefromjpeg($filename);
} elseif ($image_format == 3) {
$old_image = imagecreatefrompng($filename);
} else {
return;
}
// echo("$image_width x $image_height");
$new_image = imageCreateTrueColor($image_width, $image_height);
$white = ImageColorAllocate($new_image, 255, 255, 255);
ImageFill($new_image, 0, 0, $white);
/*imageCopyResized*/
imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $image_width, $image_height, imageSX($old_image), imageSY($old_image));
// Save to cache
if (_I_CACHING == "1" && !$_REQUEST['dc']) {
//if (!file_exists(_I_CACHE_PATH)) {
// @mkdir(_I_CACHE_PATH, 0777);
//}
if (!is_dir($path_to_cache_file)) {
@mkdir($path_to_cache_file);
}
imageJpeg($new_image, $cache);
//@chmod($cache, '0666');
}
// Endof save
Header("Content-type:image/jpeg");
imageJpeg($new_image);
}
开发者ID:vasvlad,项目名称:majordomo,代码行数:31,代码来源:thumb.php
示例17: count
$file_size = $_FILES['myfile']['size'];
$sql = "select count(id)+1 from pe.file_allegati allegati where pratica={$idpratica} and allegato={$idallegato}";
if ($desc) {
$sql = "insert into pe.file_allegati (pratica,allegato,nome_file,tipo_file,size_file,ordine,chk,uidins,tmsins,form,note) values ({$idpratica},{$idallegato},'{$file_name}','{$file_type}',{$file_size},({$sql}),1," . $_SESSION["USER_ID"] . "," . time() . ",'{$form}','{$desc}');";
} else {
$sql = "insert into pe.file_allegati (pratica,allegato,nome_file,tipo_file,size_file,ordine,chk,uidins,tmsins,form) values ({$idpratica},{$idallegato},'{$file_name}','{$file_type}',{$file_size},({$sql}),1," . $_SESSION["USER_ID"] . "," . time() . ",'{$form}');";
}
$db->sql_query($sql);
$_SESSION["ADD_NEW"] = 1;
if (DEBUG) {
echo $sql;
}
//creo l'oggetto immagine se il file è tipo immagine
if (ereg("jpeg", $file_type)) {
$im_file_name = $updDir . $file_name;
$image_attribs = getimagesize($im_file_name);
$im_old = @imageCreateFromJpeg($im_file_name);
//setto le dimensioni del thumbnail
$th_max_width = 100;
$th_max_height = 100;
$ratio = $width > $height ? $th_max_width / $image_attribs[0] : $th_max_height / $image_attribs[1];
$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;
$im_new = imagecreatetruecolor($th_width, $th_height);
//@imageantialias ($im_new,true);
//creo la thumbnail e la copio sul disco
$th_file_name = $updDir . "tmb/tmb_" . $file_name;
@imageCopyResampled($im_new, $im_old, 0, 0, 0, 0, $th_width, $th_height, $image_attribs[0], $image_attribs[1]);
@imageJpeg($im_new, $th_file_name, 100);
ini_set('max_execution_time', $var);
}
开发者ID:mamogmx,项目名称:praticaweb-alghero,代码行数:31,代码来源:upload.php
示例18: switch
}
switch ($ext) {
case "gif":
header('Content-type: image/gif');
imageGif($imgNew, $cache_path);
imageGif($imgNew);
break;
case "jpg":
header('Content-type: image/jpeg');
imageJpeg($imgNew, $cache_path);
imageJpeg($imgNew);
break;
case "jpeg":
header('Content-type: image/jpeg');
imageJpeg($imgNew, $cache_path);
imageJpeg($imgNew);
break;
case "png":
header('Content-type: image/png');
imagePng($imgNew, $cache_path);
imagePng($imgNew);
break;
}
imageDestroy($img);
imageDestroy($imgNew);
// function from docos to convert short-hand notation to bytes
function imageresize_return_bytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val) - 1]);
switch ($last) {
开发者ID:joel-cass,项目名称:structure-cms,代码行数:31,代码来源:image.php
示例19: debugMode
function debugMode($line, $message, $file = null, $config = null, $message2 = null)
{
global $im, $configData;
// Destroy the image
if (isset($im)) {
imageDestroy($im);
}
if (is_numeric($line)) {
$line -= 1;
}
$error_text = 'Error!';
$line_text = 'Line: ' . $line;
$file = !empty($file) ? 'File: ' . $file : '';
$config = $config ? 'Check the config file' : '';
$message2 = !empty($message2) ? $message2 : '';
$lines = array();
$lines[] = array('s' => $error_text, 'f' => 5, 'c' => 'red');
$lines[] = array('s' => $line_text, 'f' => 3, 'c' => 'blue');
$lines[] = array('s' => $file, 'f' => 2, 'c' => 'green');
$lines[] = array('s' => $message, 'f' => 2, 'c' => 'black');
$lines[] = array('s' => $config, 'f' => 2, 'c' => 'black');
$lines[] = array('s' => $message2, 'f' => 2, 'c' => 'black');
$height = $width = 0;
foreach ($lines as $line) {
if (strlen($line['s']) > 0) {
$line_width = ImageFontWidth($line['f']) * strlen($line['s']);
$width = $width < $line_width ? $line_width : $width;
$height += ImageFontHeight($line['f']);
}
}
$im = @imagecreate($width + 1, $height);
if ($im) {
$white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$linestep = 0;
foreach ($lines as $line) {
if (strlen($line['s']) > 0) {
imagestring($im, $line['f'], 1, $linestep, utf8_to_nce($line['s']), ${$line}['c']);
$linestep += ImageFontHeight($line['f']);
}
}
switch ($configData['image_type']) {
case 'jpeg':
case 'jpg':
header('Content-type: image/jpg');
@imageJpeg($im);
break;
case 'png':
header('Content-type: image/png');
@imagePng($im);
break;
case 'gif':
default:
header('Content-type: image/gif');
@imagegif($im);
break;
}
imageDestroy($im);
} else {
if (!empty($file)) {
$file = "[<span style=\"color:green\">{$file}</span>]";
}
$string = "<strong><span style=\"color:red\">Error!</span></strong>";
$string .= "<span style=\"color:blue\">Line {$line}:</span> {$message} {$file}\n<br /><br />\n";
if ($config) {
$string .= "{$config}\n<br />\n";
}
if (!empty($message2)) {
$string .= "{$message2}\n";
}
print $string;
}
exit;
}
开发者ID:Sajaki,项目名称:addons,代码行数:77,代码来源:index.php
示例20: redimage
//.........这里部分代码省略.........
$dh = $dw;
$dw = round($dh / $sh * $sw);
}
}
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dw, $dh, $sw, $sh);
} else {
// redim the pic according to dest W or dest H
if ($dw == 0 || $dh == 0) {
if ($dw == 0) {
$dw = round($dh / $sh * $sw);
} else {
if ($dh == 0) {
$dh = round($dw / $sw * $sh);
}
}
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dw, $dh, $sw, $sh);
} else {
if ($sw / $sh < $dw / $dh) {
$tw = $sw;
$th = round($sw / $dw * $dh);
$x = 0;
$y = round(($sh - $th) / 2);
$temp_img = ImageCreateTrueColor($tw, $th);
$dest_img = ImageCreateTrueColor($dw, $dh);
ImageCopyResampled($temp_img, $src_img, 0, 0, $x, $y, $sw, $sh, $sw, $sh);
ImageCopyResampled($dest_img, $temp_img, 0, 0, 0, 0, $dw, $dh, $tw, $th);
ImageDestroy($temp_img);
} else {
$tw = $sw;
$th = round($sw * ($dh / $dw));
$x = 0;
$y = round(($th - $sh) / 2);
$temp_img = ImageCreateTrueColor($tw, $th);
$dest_img = ImageCreateTrueColor($dw, $dh);
imagefill($temp_img, 0, 0, imagecolorallocate($dest_img, 0, 0, 0));
ImageCopyResampled($temp_img, $src_img, $x, $y, 0, 0, $sw, $sh, $sw, $sh);
ImageCopyResampled($dest_img, $temp_img, 0, 0, 0, 0, $dw, $dh, $tw, $th);
ImageDestroy($temp_img);
}
}
}
}
if ($stamp != false) {
// detect file type (could be a lot better)
$type_stamp = strtoupper(substr($stamp, -3));
// read stamp
switch ($type_stamp) {
case 'JPG':
$stamp_img = ImageCreateFromJpeg($stamp);
break;
case 'PEG':
$stamp_img = ImageCreateFromJpeg($stamp);
break;
case 'GIF':
$stamp_img = ImageCreateFromGif($stamp);
break;
case 'PNG':
$stamp_img = imageCreateFromPng($stamp);
break;
case 'BMP':
$stamp_img = imageCreatefromWBmp($stamp);
break;
}
// get it's info
$size = GetImageSize($stamp);
$stw = $size[0];
$sth = $size[1];
$sx = $dw - $stw;
$sy = $dh - $sth;
imagecolortransparent($stamp_img, imageColorAllocate($stamp_img, 0, 0, 0));
imagecopy($dest_img, $stamp_img, $sx, $sy, 0, 0, $stw, $sth);
}
// free destination
if (file_exists($dest_img)) {
unlink($dest_img);
}
// save dest image
switch ($type_dest) {
case 'JPG':
imageJpeg($dest_img, $dest, 90);
break;
case 'PEG':
imageJpeg($dest_img, $dest, 90);
break;
case 'GIF':
imageGif($dest_img, $dest, 90);
break;
case 'PNG':
imagePng($dest_img, $dest, 90);
break;
case 'BMP':
imageWBmp($dest_img, $dest, 90);
break;
}
// free memory
imageDestroy($src_img);
ImageDestroy($dest_img);
}
开发者ID:unrealloco,项目名称:mapfactory_v5,代码行数:101,代码来源:function.php
注:本文中的imageJpeg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论