本文整理汇总了PHP中imageCopyResized函数的典型用法代码示例。如果您正苦于以下问题:PHP imageCopyResized函数的具体用法?PHP imageCopyResized怎么用?PHP imageCopyResized使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageCopyResized函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: Resize
function Resize($maxwidth = 10000, $maxheight, $imagename, $filetype, $how = 'keep_aspect')
{
$target_temp_file = tempnam("jinn/temp", "gdlib_");
unlink($target_temp_file);
$target_temp_file .= '.' . $filetype;
if (!$maxheight) {
$maxheight = 10000;
}
if (!$maxwidth) {
$maxwidth = 10000;
}
$qual = 100;
$filename = $imagename;
$ext = $filetype;
list($curwidth, $curheight) = getimagesize($filename);
$factor = min($maxwidth / $curwidth, $maxheight / $curheight);
$sx = 0;
$sy = 0;
$sw = $curwidth;
$sh = $curheight;
$dx = 0;
$dy = 0;
$dw = $curwidth * $factor;
$dh = $curheight * $factor;
if ($ext == "JPEG") {
$src = ImageCreateFromJPEG($filename);
}
if ($ext == "GIF") {
$src = ImageCreateFromGIF($filename);
}
if ($ext == "PNG") {
$src = ImageCreateFromPNG($filename);
}
if (function_exists('ImageCreateTrueColor')) {
$dst = ImageCreateTrueColor($dw, $dh);
} else {
$dst = ImageCreate($dw, $dh);
}
if (function_exists('ImageCopyResampled')) {
imageCopyResampled($dst, $src, $dx, $dy, $sx, $sy, $dw, $dh, $sw, $sh);
} else {
imageCopyResized($dst, $src, $dx, $dy, $sx, $sy, $dw, $dh, $sw, $sh);
}
if ($ext == "JPEG") {
ImageJPEG($dst, $target_temp_file, $qual);
}
if ($ext == "PNG") {
ImagePNG($dst, $target_temp_file, $qual);
}
if ($ext == "GIF") {
ImagePNG($dst, $target_temp_file, $qual);
}
ImageDestroy($dst);
return $target_temp_file;
}
示例4: create_avatar
function create_avatar($imgpath, $thumbpath, $neueBreite, $neueHoehe)
{
$size = getimagesize($imgpath);
$breite = $size[0];
$hoehe = $size[1];
$RatioW = $neueBreite / $breite;
$RatioH = $neueHoehe / $hoehe;
if ($RatioW < $RatioH) {
$neueBreite = $breite * $RatioW;
$neueHoehe = $hoehe * $RatioW;
} else {
$neueBreite = $breite * $RatioH;
$neueHoehe = $hoehe * $RatioH;
}
$neueBreite = round($neueBreite, 0);
$neueHoehe = round($neueHoehe, 0);
if (function_exists('gd_info')) {
$tmp = gd_info();
$imgsup = $tmp['GIF Create Support'] ? 1 : 2;
unset($tmp);
} else {
$imgsup = 2;
}
if ($size[2] < $imgsup or $size[2] > 3) {
return false;
}
if ($size[2] == 1) {
$altesBild = imagecreatefromgif($imgpath);
} elseif ($size[2] == 2) {
$altesBild = imagecreatefromjpeg($imgpath);
} elseif ($size[2] == 3) {
$altesBild = imagecreatefrompng($imgpath);
}
if (function_exists('imagecreatetruecolor') and $size[2] != 1) {
$neuesBild = png_create_transparent($neueBreite, $neueHoehe);
imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
} elseif (function_exists('imagecreatetruecolor') and $size[2] == 1) {
$neuesBild = imageCreate($neueBreite, $neueHoehe);
gif_create_transparent($neuesBild, $altesBild);
imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
} else {
$neuesBild = imageCreate($neueBreite, $neueHoehe);
imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
}
if ($size[2] == 1) {
ImageGIF($neuesBild, $thumbpath);
} elseif ($size[2] == 2) {
ImageJPEG($neuesBild, $thumbpath);
} elseif ($size[2] == 3) {
ImagePNG($neuesBild, $thumbpath);
}
return true;
}
示例5: __resize
/**
* Do the actual resize of an image
*
* @param Asido_TMP &$tmp
* @param integer $width
* @param integer $height
* @return boolean
* @access protected
*/
function __resize(&$tmp, $width, $height)
{
// create new target
//
$_ = imageCreateTrueColor($width, $height);
imageSaveAlpha($_, true);
imageAlphaBlending($_, false);
$r = imageCopyResized($_, $tmp->target, 0, 0, 0, 0, $width, $height, $tmp->image_width, $tmp->image_height);
// set new target
//
$this->__destroy_target($tmp);
$tmp->target = $_;
return $r;
}
示例6: create_thumb
function create_thumb($imgpath, $thumbpath, $neueBreite)
{
$size = getimagesize($imgpath);
$breite = $size[0];
$hoehe = $size[1];
$neueHoehe = intval($hoehe * $neueBreite / $breite);
if (function_exists('gd_info')) {
$tmp = gd_info();
$imgsup = $tmp['GIF Create Support'] ? 1 : 2;
unset($tmp);
} else {
$imgsup = 2;
}
if ($size[2] < $imgsup or $size[2] > 3) {
return FALSE;
}
if ($size[2] == 1) {
$altesBild = imagecreatefromgif($imgpath);
} elseif ($size[2] == 2) {
$altesBild = imagecreatefromjpeg($imgpath);
} elseif ($size[2] == 3) {
$altesBild = imagecreatefrompng($imgpath);
}
if (function_exists('imagecreatetruecolor') and $size[2] != 1) {
$neuesBild = imagecreatetruecolor($neueBreite, $neueHoehe);
imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
} else {
$neuesBild = imageCreate($neueBreite, $neueHoehe);
imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
}
if ($size[2] == 1) {
ImageGIF($neuesBild, $thumbpath);
} elseif ($size[2] == 2) {
ImageJPEG($neuesBild, $thumbpath);
} elseif ($size[2] == 3) {
ImagePNG($neuesBild, $thumbpath);
}
return TRUE;
}
示例7: CreatThumb
public function CreatThumb($filetype, $tsrc, $dest, $n_width, $n_height)
{
if ($filetype == "gif") {
$im = ImageCreateFromGIF($dest);
// Original picture width is stored
$width = ImageSx($im);
// Original picture height is stored
$height = ImageSy($im);
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
ImageGIF($newimage, $tsrc);
chmod("{$tsrc}", 0755);
}
if ($filetype == "jpg") {
$im = ImageCreateFromJPEG($dest);
// Original picture width is stored
$width = ImageSx($im);
// Original picture height is stored
$height = ImageSy($im);
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
ImageJpeg($newimage, $tsrc);
chmod("{$tsrc}", 0755);
}
if ($filetype == "png") {
$im = ImageCreateFromPNG($dest);
// Original picture width is stored
$width = ImageSx($im);
// Original picture height is stored
$height = ImageSy($im);
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
imagepng($newimage, $tsrc);
chmod("{$tsrc}", 0755);
}
}
示例8: copyResource
/**
* Copy an existing internal image resource, or part of it, to this Image instance
* @param resource existing internal image resource as source for the copy
* @param int x x-coordinate where the copy starts
* @param int y y-coordinate where the copy starts
* @param int resourceX starting x coordinate of the source image resource
* @param int resourceY starting y coordinate of the source image resource
* @param int width resulting width of the copy (not of the resulting image)
* @param int height resulting height of the copy (not of the resulting image)
* @param int resourceWidth width of the source image resource to copy
* @param int resourceHeight height of the source image resource to copy
* @return null
*/
protected function copyResource($resource, $x, $y, $resourceX, $resourceY, $width, $height, $resourceWidth, $resourceHeight)
{
if (!imageCopyResampled($this->resource, $resource, $x, $y, $resourceX, $resourceY, $width, $height, $resourceWidth, $resourceHeight)) {
if (!imageCopyResized($this->resource, $resource, $x, $y, $resourceX, $resourceY, $width, $height, $resourceWidth, $resourceHeight)) {
throw new ImageException('Could not copy the image resource');
}
}
$transparent = imageColorAllocate($this->resource, 0, 0, 0);
imageColorTransparent($this->resource, $transparent);
$this->width = $width;
$this->height = $height;
}
示例9: geraFotos
function geraFotos($fotoOriginal)
{
if (!file_exists($fotoOriginal)) {
return;
}
list($imagewidth, $imageheight, $img_type) = @GetImageSize($fotoOriginal);
$src_img_original = '';
$fim_largura = $imagewidth;
$fim_altura = $imageheight;
$extensao = $img_type == 2 ? '.jpg' : ($img_type == 3 ? '.png' : '');
$nome_do_arquivo = array_pop(explode('/', $fotoOriginal)) . $extensao;
$caminhoDaBig = 'arquivos/educar/aluno/big/' . $nome_do_arquivo;
$caminhoDaFotoOriginal = 'arquivos/educar/aluno/original/' . $nome_do_arquivo;
if ($imagewidth > 700) {
$new_w = 700;
$ratio = $imagewidth / $new_w;
$new_h = ceil($imageheight / $ratio);
$fim_largura = $new_w;
$fim_altura = $new_h;
if (!file_exists($caminhoDaBig)) {
if ($img_type == 2) {
$src_img_original = @imagecreatefromjpeg($fotoOriginal);
$dst_img = @imagecreatetruecolor($new_w, $new_h);
imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
imagejpeg($dst_img, $caminhoDaBig);
} elseif ($img_type == 3) {
$src_img_original = @ImageCreateFrompng($fotoOriginal);
$dst_img = @imagecreatetruecolor($new_w, $new_h);
ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
Imagepng($dst_img, $caminhoDaBig);
}
}
} else {
if (!file_exists($caminhoDaBig)) {
copy($fotoOriginal, $caminhoDaBig);
if ($img_type == 2) {
$src_img_original = @imagecreatefromjpeg($fotoOriginal);
} elseif ($img_type == 3) {
$src_img_original = @imagecreatefrompng($fotoOriginal);
}
}
}
$new_w = 100;
$ratio = $imagewidth / $new_w;
$new_h = round($imageheight / $ratio);
$caminhoDaSmall = 'arquivos/educar/aluno/small/' . $nome_do_arquivo;
if (file_exists($caminhoDaBig)) {
if ($img_type == 2) {
$dst_img = @imagecreatetruecolor($new_w, $new_h);
@imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
@imagejpeg($dst_img, $caminhoDaSmall);
} elseif ($img_type == 3) {
$dst_img = @imagecreatetruecolor($new_w, $new_h);
@imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original));
@imagepng($dst_img, $caminhoDaSmall);
} elseif ($img_type == 1) {
$dst_img = @imagecreatefromgif($src_img_original);
@imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original));
@imagegif($dst_img, $caminhoDaSmall);
}
}
copy($fotoOriginal, $caminhoDaFotoOriginal);
if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) {
die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>");
}
if (file_exists($fotoOriginal)) {
unlink($fotoOriginal);
}
return $nome_do_arquivo;
}
示例10: imagefill
imagefill($im_resized, 0, 0, $white_color);
$old_w = imagesx($im);
$old_h = imagesy($im);
$old_rate = $old_w / $old_h;
if ($old_rate == $new_rate) {
imageCopyResized($im_resized, $im, 0, 0, 0, 0, $w, $h, $old_w, $old_h);
} else {
if ($old_w > $old_h) {
$tmp_h = $h;
$tmp_w = $tmp_h * $old_rate;
$tmp_im = imageCreate($tmp_w, $tmp_h);
$white_color = imagecolorallocate($tmp_im, 255, 255, 255);
imagefill($tmp_im, 0, 0, $white_color);
imageCopyResized($tmp_im, $im, 0, 0, 0, 0, $tmp_w, $tmp_h, $old_w, $old_h);
imageCopyResized($im_resized, $tmp_im, 0, 0, round(($tmp_w - $w) / 2), 0, $w, $h, $w, $h);
imagedestroy($tmp_im);
} else {
$tmp_w = $w;
$tmp_h = $tmp_w / $old_rate;
$tmp_im = imageCreate($tmp_w, $tmp_h);
$white_color = imagecolorallocate($tmp_im, 255, 255, 255);
imagefill($tmp_im, 0, 0, $white_color);
imageCopyResized($tmp_im, $im, 0, 0, 0, 0, $tmp_w, $tmp_h, $old_w, $old_h);
imageCopyResized($im_resized, $tmp_im, 0, 0, 0, round(($tmp_h - $h) / 2), $w, $h, $w, $h);
imagedestroy($tmp_im);
}
}
header('Content-Type: image/jpeg');
imagejpeg($im_resized);
imagedestroy($im);
imagedestroy($im_resized);
示例11: Novo
function Novo()
{
global $HTTP_POST_FILES;
if (!empty($HTTP_POST_FILES['foto']['name'])) {
$fotoOriginal = "tmp/" . $HTTP_POST_FILES['foto']['name'];
if (file_exists($fotoOriginal)) {
unlink($fotoOriginal);
}
copy($HTTP_POST_FILES['foto']['tmp_name'], $fotoOriginal);
list($imagewidth, $imageheight, $img_type) = getImageSize($fotoOriginal);
$src_img_original = "";
$fim_largura = $imagewidth;
$fim_altura = $imageheight;
$extensao = $img_type == "2" ? ".jpg" : ($img_type == "3" ? ".png" : "");
$nome_do_arquivo = date('Y-m-d-h-i') . "-" . substr(md5($fotoOriginal), 0, 10) . $extensao;
$caminhoDaBig = "fotos/big/{$nome_do_arquivo}";
$caminhoDaSBig = "fotos/sbig/{$nome_do_arquivo}";
if ($imagewidth > 700 && $imageheight < $imagewidth) {
$new_w = 500;
$ratio = $imagewidth / $new_w;
$new_h = ceil($imageheight / $ratio);
if (!file_exists($caminhoDaBig)) {
if ($img_type == "2") {
$src_img_original = imagecreatefromjpeg($fotoOriginal);
$dst_img = imagecreatetruecolor($new_w, $new_h);
imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
imagejpeg($dst_img, $caminhoDaBig);
} else {
if ($img_type == "3") {
$src_img_original = @ImageCreateFrompng($fotoOriginal);
$dst_img = @imagecreatetruecolor($new_w, $new_h);
ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
Imagepng($dst_img, $caminhoDaBig);
}
}
}
} elseif ($imagewidth > 400 && $imageheight > $imagewidth) {
$new_w = 400;
$ratio = $imagewidth / $new_w;
$new_h = ceil($imageheight / $ratio);
$fim_largura = $new_w;
$fim_altura = $new_h;
if (!file_exists($caminhoDaBig)) {
if ($img_type == "2") {
$src_img_original = @imagecreatefromjpeg($fotoOriginal);
$dst_img = @imagecreatetruecolor($new_w, $new_h);
imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
imagejpeg($dst_img, $caminhoDaBig);
} else {
if ($img_type == "3") {
$src_img_original = @ImageCreateFrompng($fotoOriginal);
$dst_img = @imagecreatetruecolor($new_w, $new_h);
ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original));
Imagepng($dst_img, $caminhoDaBig);
}
}
}
} else {
if (!file_exists($caminhoDaBig)) {
copy($fotoOriginal, $caminhoDaBig);
if ($img_type == "2") {
$src_img_original = @imagecreatefromjpeg($fotoOriginal);
} else {
if ($img_type == "3") {
$src_img_original = @imagecreatefrompng($fotoOriginal);
}
}
}
}
$new_w = 100;
$ratio = $imagewidth / $new_w;
$new_h = round($imageheight / $ratio);
$caminhoDaSmall = "fotos/small/{$nome_do_arquivo}";
if (!file_exists($caminhoDaSmall)) {
if ($img_type == "2") {
$dst_img = @imagecreatetruecolor($new_w, $new_h);
@imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original));
@imagejpeg($dst_img, $caminhoDaSmall);
} else {
if ($img_type == "3") {
$dst_img = @imagecreatetruecolor($new_w, $new_h);
@imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original));
@imagepng($dst_img, $caminhoDaSmall);
}
}
}
copy($fotoOriginal, $caminhoDaSBig);
if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) {
die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>");
}
} else {
return false;
}
@session_start();
$this->id_pessoa = @$_SESSION['id_pessoa'];
session_write_close();
$this->data_foto = str_replace("%2F", "/", $this->data_foto);
$db = new clsBanco();
$db->Consulta("INSERT INTO foto_portal ( nm_credito, ref_cod_foto_secao, ref_ref_cod_pessoa_fj, data_foto, titulo, descricao, caminho, altura, largura ) VALUES ( '{$this->nm_credito}', '1', {$this->id_pessoa}, now(), '{$this->titulo}', '{$this->descricao}', '{$nome_do_arquivo}', {$fim_largura}, {$fim_altura} )");
echo "<script>document.location='fotos_lst.php';</script>";
//.........这里部分代码省略.........
示例12: resizeImage
/**
* Generate images of alternate sizes.
*/
function resizeImage($cnvrt_arry)
{
global $platform, $imgs, $cnvrt_path, $reqd_image, $convert_writable, $convert_magick, $convert_GD, $convert_cmd, $cnvrt_alt, $cnvrt_mesgs, $compat_quote;
if (empty($imgs) || $convert_writable == FALSE) {
return;
}
if ($convert_GD == TRUE && !($gd_version = gdVersion())) {
return;
}
if ($cnvrt_alt['no_prof'] == TRUE) {
$strip_prof = ' +profile "*"';
} else {
$strip_prof = '';
}
if ($cnvrt_alt['mesg_on'] == TRUE) {
$str = '';
}
foreach ($imgs as $img_file) {
if ($cnvrt_alt['indiv'] == TRUE && $img_file != $reqd_image['file']) {
continue;
}
$orig_img = $reqd_image['pwd'] . '/' . $img_file;
$cnvrtd_img = $cnvrt_path . '/' . $cnvrt_arry['prefix'] . $img_file;
if (!is_file($cnvrtd_img)) {
$img_size = GetImageSize($orig_img);
$height = $img_size[1];
$width = $img_size[0];
$area = $height * $width;
$maxarea = $cnvrt_arry['maxwid'] * $cnvrt_arry['maxwid'] * 0.9;
$maxheight = $cnvrt_arry['maxwid'] * 0.75 + 1;
if ($area > $maxarea || $width > $cnvrt_arry['maxwid'] || $height > $maxheight) {
if ($width / $cnvrt_arry['maxwid'] >= $height / $maxheight) {
$dim = 'W';
}
if ($height / $maxheight >= $width / $cnvrt_arry['maxwid']) {
$dim = 'H';
}
if ($dim == 'W') {
$cnvt_percent = round(0.9375 * $cnvrt_arry['maxwid'] / $width * 100, 2);
}
if ($dim == 'H') {
$cnvt_percent = round(0.75 * $cnvrt_arry['maxwid'] / $height * 100, 2);
}
// convert it
if ($convert_magick == TRUE) {
// Image Magick image conversion
if ($platform == 'Win32' && $compat_quote == TRUE) {
$winquote = '"';
} else {
$winquote = '';
}
exec($winquote . $convert_cmd . ' -geometry ' . $cnvt_percent . '%' . ' -quality ' . $cnvrt_arry['qual'] . ' -sharpen ' . $cnvrt_arry['sharpen'] . $strip_prof . ' "' . $orig_img . '"' . ' "' . $cnvrtd_img . '"' . $winquote);
$using = $cnvrt_mesgs['using IM'];
} elseif ($convert_GD == TRUE) {
// GD image conversion
if (eregi('\\.jpg$|\\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) {
$src_img = imageCreateFromJpeg($orig_img);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) {
$src_img = imageCreateFromPng($orig_img);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) {
$src_img = imageCreateFromGif($orig_img);
} else {
continue;
}
$src_width = imageSx($src_img);
$src_height = imageSy($src_img);
$dest_width = $src_width * ($cnvt_percent / 100);
$dest_height = $src_height * ($cnvt_percent / 100);
if ($gd_version >= 2) {
$dst_img = imageCreateTruecolor($dest_width, $dest_height);
imageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
} else {
$dst_img = imageCreate($dest_width, $dest_height);
imageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
}
imageDestroy($src_img);
if (eregi('\\.jpg$|\\.jpeg$/i', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) {
imageJpeg($dst_img, $cnvrtd_img, $cnvrt_arry['qual']);
} elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) {
imagePng($dst_img, $cnvrtd_img);
} elseif (eregi('\\.gif$/i', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) {
imageGif($dst_img, $cnvrtd_img);
}
imageDestroy($dst_img);
$using = $cnvrt_mesgs['using GD'] . $gd_version;
}
if ($cnvrt_alt['mesg_on'] == TRUE && is_file($cnvrtd_img)) {
$str .= " <small>\n" . ' ' . $cnvrt_mesgs['generated'] . $cnvrt_arry['txt'] . $cnvrt_mesgs['converted'] . $cnvrt_mesgs['image_for'] . $img_file . $using . ".\n" . " </small>\n <br />\n";
}
}
}
}
if (isset($str)) {
return $str;
}
}
示例13: make_thumbnails
private function make_thumbnails($updir, $img)
{
$thumbnail_width = 146;
$thumbnail_height = 116;
$thumb_preword = "thumb_";
$arr_image_details = GetImageSize("{$updir}" . "{$img}");
$original_width = $arr_image_details[0];
$original_height = $arr_image_details[1];
if ($original_width > $original_height) {
$new_width = $thumbnail_width;
$new_height = intval($original_height * $new_width / $original_width);
} else {
$new_height = $thumbnail_height;
$new_width = intval($original_width * $new_height / $original_height);
}
$dest_x = intval(($thumbnail_width - $new_width) / 2);
$dest_y = intval(($thumbnail_height - $new_height) / 2);
if ($arr_image_details[2] == 1) {
$imgt = "ImageGIF";
$imgcreatefrom = "ImageCreateFromGIF";
}
if ($arr_image_details[2] == 2) {
$imgt = "ImageJPEG";
$imgcreatefrom = "ImageCreateFromJPEG";
}
if ($arr_image_details[2] == 3) {
$imgt = "ImagePNG";
$imgcreatefrom = "ImageCreateFromPNG";
}
if ($imgt) {
$old_image = $imgcreatefrom("{$updir}" . "{$img}");
$new_image = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
imageCopyResized($new_image, $old_image, 0, 0, 0, 0, 146, 116, $original_width, $original_height);
$imgt($new_image, "{$updir}" . "{$thumb_preword}" . "{$img}");
}
}
示例14: border
public function border($size, $color)
{
if (!$this->_processedImage) {
return false;
}
if (is_array($color)) {
list($red, $green, $blue) = $color;
} else {
list($red, $green, $blue) = PGRThumb_Utils::html2rgb($color);
}
$width = $this->_width + 2 * $size;
$height = $this->_height + 2 * $size;
$newimage = imagecreatetruecolor($width, $height);
$border_color = imagecolorallocate($newimage, $red, $green, $blue);
imagefilledrectangle($newimage, 0, 0, $width, $height, $border_color);
$res = imageCopyResized($newimage, $this->_processedImage, $size, $size, 0, 0, $this->_width, $this->_height, $this->_width, $this->_height);
if ($res) {
$this->_processedImage = $newimage;
}
$this->_width = $width;
$this->_height = $height;
return $res;
}
示例15: upMultImageWithThumb
function upMultImageWithThumb($destpath, $thumbPath, $file, $n_width, $n_height)
{
$path = '';
while (list($key, $value) = each($_FILES[$file]["name"])) {
if (!empty($value)) {
if ($_FILES[$file]["type"][$key] == "image/gif" || $_FILES[$file]["type"][$key] == "image/jpeg" || $_FILES[$file]["type"][$key] == "image/pjpeg" || $_FILES[$file]["type"][$key] == "image/png" && $_FILES[$file]["size"][$key] < 2000000) {
$source = $_FILES[$file]["tmp_name"][$key];
$filename = $_FILES[$file]["name"][$key];
move_uploaded_file($source, $destpath . $filename);
//echo "Uploaded: " . $destpath . $filename . "<br/>" ;
$path .= $filename . '***';
//thumbnail creation start//
$tsrc = $thumbPath . $_FILES[$file]["name"][$key];
// Path where thumb nail image will be stored
//$n_width = 100; // Fix the width of the thumb nail images
//$n_height = 100; // Fix the height of the thumb nail imaage
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
$add = $destpath . $filename;
if ($_FILES[$file]["type"][$key] == "image/gif") {
//echo "hello";
$im = ImageCreateFromGIF($add);
$width = ImageSx($im);
// Original picture width is stored
$height = ImageSy($im);
// Original picture height is stored
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage, $tsrc);
}
if (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage, $tsrc);
}
}
//chmod("$tsrc",0777);
////////// end of gif file thumb nail creation//////////
//$n_width=100; // Fix the width of the thumb nail images
//$n_height=100; // Fix the height of the thumb nail imaage
////////////// starting of JPG thumb nail creation//////////
if ($_FILES[$file]["type"][$key] == "image/jpeg") {
//echo $_FILES[$file]["name"][$key]."<br>";
$im = ImageCreateFromJPEG($add);
$width = ImageSx($im);
// Original picture width is stored
$height = ImageSy($im);
// Original picture height is stored
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
ImageJpeg($newimage, $tsrc);
chmod("{$tsrc}", 0777);
}
//////////////// End of png thumb nail creation //////////
if ($_FILES[$file]["type"][$key] == "image/png") {
//echo "hello";
$im = ImageCreateFromPNG($add);
$width = ImageSx($im);
// Original picture width is stored
$height = ImageSy($im);
// Original picture height is stored
$newimage = imagecreatetruecolor($n_width, $n_height);
imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
if (function_exists("imagepng")) {
//Header("Content-type: image/png");
ImagePNG($newimage, $tsrc);
}
if (function_exists("imagejpeg")) {
//Header("Content-type: image/jpeg");
ImageJPEG($newimage, $tsrc);
}
}
// thumbnail creation end---
} else {
$msg = "error in upload";
//return $msg;
}
}
//if
}
//while
$cnt = strlen($path) - 3;
$pathnw = substr_replace($path, '', $cnt, 3);
return $pathnw;
}