本文整理汇总了PHP中ImagesX函数的典型用法代码示例。如果您正苦于以下问题:PHP ImagesX函数的具体用法?PHP ImagesX怎么用?PHP ImagesX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImagesX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize
public function resize($width, $height)
{
$type = exif_imagetype($this->image);
if ($type == 2) {
$images_orig = ImageCreateFromJPEG($this->image);
} elseif ($type == 3) {
$images_orig = ImageCreateFromPNG($this->image);
} elseif ($type == 1) {
$images_orig = ImageCreateFromGIF($this->image);
} else {
return false;
}
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
if ($type == 2) {
ImageJPEG($images_fin, $this->image);
} elseif ($type == 3) {
ImagePNG($images_fin, $this->image);
} elseif ($type == 1) {
ImageGIF($images_fin, $this->image);
}
ImageDestroy($images_orig);
ImageDestroy($images_fin);
return true;
}
示例2: update_picture
public function update_picture()
{
if (trim($_FILES["myfile"]["tmp_name"]) != "") {
$images = $_FILES["myfile"]["tmp_name"];
$new_images = "thumb_" . $this->session->userdata('std_cardid') . '_' . $_FILES["myfile"]["name"];
copy($_FILES["myfile"]["tmp_name"], "assets/uploads/photo/" . $_FILES["myfile"]["name"]);
$width = 150;
//*** Fix Width & Heigh (Autu caculate) ***//
$size = GetimageSize($images);
$height = round($width * $size[1] / $size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, "assets/uploads/photo/" . $new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
$fileName = $_FILES["myfile"]["name"];
$ret[] = $fileName;
$data_picture = array('std_picture' => $new_images);
$this->Students_model->update_student_picture($this->session->userdata('std_cardid'), $data_picture);
//echo base_url()."assets/uploads/photo/".$new_images;
redirect('/front_profiles/student_edit', 'refresh');
//ChromePhp::log($ret);
//exit;
}
示例3: makeThumb
function makeThumb($path, $size, $mime = FALSE)
{
// Verifica se é uma imagem
// @since rev 1
if ($mime === FALSE) {
$mime = mime_content_type($path);
}
if (strpos($mime, "jpeg") !== FALSE) {
$buffer = imagecreatefromjpeg($path);
} elseif (strpos($mime, "bmp") !== FALSE) {
$buffer = imagecreatefrombmp($path);
} elseif (strpos($mime, "gif") !== FALSE) {
$buffer = imagecreatefromgif($path);
} elseif (strpos($mime, "png") !== FALSE) {
$buffer = imagecreatefrompng($path);
} else {
return FALSE;
}
if ($buffer === FALSE) {
return FALSE;
}
// Busca o tamanho da imagem
// @since rev 1
$x = $origem_x = ImagesX($buffer);
$y = $origem_y = ImagesY($buffer);
// Verifica qual deve ser a proporção
// @since rev 1
if ($x >= $y) {
if ($x > $size) {
$x1 = (int) ($x * ($size / $x));
$y1 = (int) ($y * ($size / $x));
} else {
$x1 = $x;
$y1 = $y;
}
} else {
if ($y > $size) {
$x1 = (int) ($x * ($size / $y));
$y1 = (int) ($y * ($size / $y));
} else {
$x1 = $x;
$y1 = $y;
}
}
// Muda o tamanho da imagem
// @since rev 1
$image = ImageCreateTrueColor($x1, $y1);
if ($image === FALSE) {
return FALSE;
}
ImageCopyResampled($image, $buffer, 0, 0, 0, 0, $x1 + 1, $y1 + 1, $origem_x, $origem_y);
// Libera recursos
// @since rev 1
ImageDestroy($buffer);
// Retorna o resource
// @since rev 1
return $image;
}
示例4: resize
function resize($image_tmp, $image_name, $width_size, $folder)
{
$images = $image_tmp;
$new_images = $image_name;
$width = $width_size;
$size = GetimageSize($images);
$height = round($width * $size[1] / $size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, $folder . $new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
示例5: thumb_creator
function thumb_creator($source, $filename, $uploaddir)
{
$extension = "." . getExtension($filename);
$new_images = "thumb_" . date(YmdHis) . $extension;
$tmp_img = $source['tmp_name'];
$src_size = getimagesize($tmp_img);
$width = 150;
$height = round($width * $src_size[1] / $src_size[0]);
if ($src_size['mime'] === 'image/jpeg') {
$src = imagecreatefromjpeg($tmp_img);
} else {
if ($src_size['mime'] === 'image/jpg') {
$src = imagecreatefromjpeg($tmp_img);
} else {
if ($src_size['mime'] === 'image/png') {
$src = imagecreatefrompng($tmp_img);
} else {
if ($src_size['mime'] === 'image/gif') {
$src = imagecreatefromgif($tmp_img);
}
}
}
}
$photoX = ImagesX($src);
$photoY = ImagesY($src);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $src, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
if ($src_size['mime'] === 'image/jpeg') {
ImageJPEG($images_fin, $uploaddir . "/" . $new_images);
} else {
if ($src_size['mime'] === 'image/jpg') {
ImageJPEG($images_fin, $uploaddir . "/" . $new_images);
} else {
if ($src_size['mime'] === 'image/png') {
ImagePNG($images_fin, $uploaddir . "/" . $new_images);
} else {
if ($src_size['mime'] === 'image/gif') {
ImageGIF($images_fin, $uploaddir . "/" . $new_images);
}
}
}
}
}
示例6: setThumbnail
/**
* Thumbnail kép készítése
*/
function setThumbnail()
{
global $sugar_config;
if (!empty($this->destination)) {
$size = getimagesize($this->destination);
$height = 200;
$ratio = $size[0] / $size[1];
$width = round($height * $ratio);
$images_orig = $this->imagecreatefromfile($this->destination);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_thumb = ImageCreateTrueColor($width, $height);
if (!ImageCopyResampled($images_thumb, $images_orig, 0, 0, 0, 0, $width, $height, $photoX, $photoY)) {
die("ERROR: can't resize the image");
} else {
ImageJPEG($images_thumb, $sugar_config['cache_dir'] . "images/thumb/" . $this->fileName);
}
}
}
示例7: testThisDoesNotWorkAsExpected
function testThisDoesNotWorkAsExpected()
{
$scale = 0.75;
$input_jpeg = new PelJpeg($this->file);
$original = ImageCreateFromString($input_jpeg->getBytes());
$original_w = ImagesX($original);
$original_h = ImagesY($original);
$scaled_w = $original_w * $scale;
$scaled_h = $original_h * $scale;
$scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
$output_jpeg = new PelJpeg($scaled);
$exif = $input_jpeg->getExif();
if ($exif !== null) {
$output_jpeg->setExif($exif);
}
file_put_contents($this->file, $output_jpeg->getBytes());
$jpeg = new PelJpeg($this->file);
$exifin = $jpeg->getExif();
$this->assertEquals($exif, $exifin);
}
示例8: uploadImage
public function uploadImage($file, $path, $resize = [400, 200, 100])
{
$filename = "photo_" . date('YmdHis') . "_" . rand() . $file->getClientOriginalName();
$file_path = public_path() . $path;
$file->move($file_path, $filename);
$size = getimagesize($file_path . $filename);
switch (strtolower($size['mime'])) {
case 'image/png':
$source_image = imagecreatefrompng($file_path . $filename);
break;
case 'image/jpeg':
$source_image = imagecreatefromjpeg($file_path . $filename);
break;
case 'image/gif':
$source_image = imagecreatefromgif($file_path . $filename);
break;
default:
die('image type not supported');
}
$resize_url = [];
foreach ($resize as $key => $value) {
$width = $value;
$height = round($width * $size[1] / $size[0]);
$photoX = ImagesX($source_image);
$photoY = ImagesY($source_image);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $source_image, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
if (!file_exists($file_path . 'x' . $value)) {
mkdir($file_path . 'x' . $value);
}
$resize_url[] = $path . 'x' . $value . '/' . $filename;
ImageJPEG($images_fin, $file_path . 'x' . $value . '/' . $filename, 100);
}
ImageDestroy($source_image);
ImageDestroy($images_fin);
return ['__type' => 'File', 'name' => $filename, 'url' => $path . $filename, 'resize_url' => $resize_url];
}
示例9: Img
function Img($Image, $Dw = 200, $Dh = 300, $Type = 2)
{
if (!File_Exists($Image)) {
return False;
}
#如果需要生成缩略图,则将原图拷贝一下重新给$Image赋值
// IF($Type!=1){
Copy($Image, Str_Replace(".", "_x.", $Image));
$Image = Str_Replace(".", "_x.", $Image);
// }
var_dump($Image);
#取得文件的类型,根据不同的类型建立不同的对象
$ImgInfo = GetImageSize($Image);
var_dump($ImgInfo);
switch ($ImgInfo[2]) {
case 1:
$Img = @ImageCreateFromGIF($Image);
break;
case 2:
$Img = @ImageCreateFromJPEG($Image);
break;
case 3:
$Img = @ImageCreateFromPNG($Image);
break;
}
#如果对象没有创建成功,则说明非图片文件
if (empty($Img)) {
#如果是生成缩略图的时候出错,则需要删掉已经复制的文件
if ($Type != 1) {
Unlink($Image);
}
return False;
}
#如果是执行调整尺寸操作则
if ($Type == 1) {
$w = ImagesX($Img);
$h = ImagesY($Img);
$width = $w;
$height = $h;
if ($width > $Dw) {
$Par = $Dw / $width;
$width = $Dw;
$height = $height * $Par;
if ($height > $Dh) {
$Par = $Dh / $height;
$height = $Dh;
$width = $width * $Par;
}
} elseif ($height > $Dh) {
$Par = $Dh / $height;
$height = $Dh;
$width = $width * $Par;
if ($width > $Dw) {
$Par = $Dw / $width;
$width = $Dw;
$height = $height * $Par;
}
} else {
$width = $width;
$height = $height;
}
$nImg = ImageCreateTrueColor($width, $height);
#新建一个真彩色画布
ImageCopyReSampled($nImg, $Img, 0, 0, 0, 0, $width, $height, $w, $h);
#重采样拷贝部分图像并调整大小
ImageJpeg($nImg, $Image);
#以JPEG格式将图像输出到浏览器或文件
return True;
#如果是执行生成缩略图操作则
} else {
$w = ImagesX($Img);
$h = ImagesY($Img);
$width = $w;
$height = $h;
$nImg = ImageCreateTrueColor($Dw, $Dh);
if ($h / $w > $Dh / $Dw) {
#高比较大
$width = $Dw;
$height = $h * $Dw / $w;
$IntNH = $height - $Dh;
ImageCopyReSampled($nImg, $Img, 0, -$IntNH / 1.8, 0, 0, $Dw, $height, $w, $h);
} else {
#宽比较大
$height = $Dh;
$width = $w * $Dh / $h;
$IntNW = $width - $Dw;
ImageCopyReSampled($nImg, $Img, -$IntNW / 1.8, 0, 0, 0, $width, $Dh, $w, $h);
}
ImageJpeg($nImg, $Image);
return True;
}
}
示例10: uploadimg
function uploadimg($filename, $width, $get_height, $path)
{
if (trim($_FILES["image"]["tmp_name"]) != "") {
$tmp_images = $_FILES["image"]["tmp_name"];
// type select
if ($_FILES['image']['type'] == 'image/jpeg' or $_FILES['image']['type'] == 'image/jpg' or $_FILES['image']['type'] == 'image/pjpeg') {
$images = $filename . ".jpg";
//upload source image
$size = getimagesize($tmp_images);
//check radio widht and height
$height = round($width * $size[1] / $size[0]);
if ($height > $get_height) {
$width = round($get_height * $size[0] / $size[1]);
$height = $get_height;
}
$images_orig = ImageCreateFromJPEG($tmp_images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, $path . $images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
return $filename . ".jpg";
} elseif ($_FILES['image']['type'] == 'image/x-png' or $_FILES['image']['type'] == 'image/png') {
$images = $filename . ".png";
$size = getimagesize($tmp_images);
//check radio widht and height
$height = round($width * $size[1] / $size[0]);
if ($height > $get_height) {
$width = round($get_height * $size[0] / $size[1]);
$height = $get_height;
}
$images_orig = ImageCreateFromPNG($tmp_images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
Imagepng($images_fin, $path . $images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
return $filename . ".png";
} elseif ($_FILES['image']['type'] == 'image/gif') {
$images = $filename . ".gif";
$size = getimagesize($tmp_images);
//check radio widht and height
$height = round($width * $size[1] / $size[0]);
if ($height > $get_height) {
$width = round($get_height * $size[0] / $size[1]);
$height = $get_height;
}
$images_orig = ImageCreateFromgif($tmp_images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
Imagegif($images_fin, $path . $images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
return $filename . ".gif";
} else {
return FALSE;
}
}
}
示例11: thumbMaker
function thumbMaker($imagem, $aprox, $id, $mini, $diretorio)
{
if (!file_exists($imagem)) {
echo "<center><h3>Imagem não encontrada.</h3></center>";
return false;
}
// verifica se está executando sob windows ou unix-like, para a
// aplicação do separador de diretórios correto.
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$barra = "\\";
} else {
$barra = "/";
}
// obtém a extensão pelo mime-type
$ext = $this->getExt($imagem);
if (!$ext) {
echo "<center><h3>Tipo inválido</h3></center>";
return false;
}
// separa o nome do arquivo do(s) diretório(s)
$dir_arq = explode($barra, $imagem);
// monta o nome do arquivo a ser gerado (thumbnail). O sizeof abaixo obtém o número de itens
// no array, dessa forma podemos pegar somente o nome do arquivo, não importando em que
// diretório está.
$i = sizeof($dir_arq) - 1;
// pega o nome do arquivo, sem os diretórios
$arquivo_miniatura = ".." . $barra . ".." . $barra . "images" . $barra . $diretorio . $barra . $mini;
// imagem de origem
if ($ext == "png") {
$img_origem = imagecreatefrompng($imagem);
} elseif ($ext == "jpg") {
$img_origem = imagecreatefromjpeg($imagem);
} elseif ($ext == "gif") {
$img_origem = imagecreatefromgif($imagem);
}
// obtém as dimensões da imagem original
$origem_x = ImagesX($img_origem);
$origem_y = ImagesY($img_origem);
$x = $origem_x;
$y = $origem_y;
// Aqui é feito um cálculo para aproximar o tamanho da imagem ao valor passado em $aprox.
// Não importa se a foto for grande ou pequena, o thumb de todas elas será mais ou menos do
// mesmo tamanho.
if ($x >= $y) {
if ($x > $aprox) {
$x1 = (int) ($x * ($aprox / $x));
$y1 = (int) ($y * ($aprox / $x));
} else {
$x1 = $x;
$y1 = $y;
}
} else {
if ($y > $aprox) {
$x1 = (int) ($x * ($aprox / $y));
$y1 = (int) ($y * ($aprox / $y));
} else {
$x1 = $x;
$y1 = $y;
}
}
$x = $x1;
$y = $y1;
// cria a imagem do thumbnail
$img_final = ImageCreateTrueColor($x, $y);
ImageCopyResampled($img_final, $img_origem, 0, 0, 0, 0, $x + 1, $y + 1, $origem_x, $origem_y);
// o arquivo é gravado
if ($ext == "png") {
imagepng($img_final, $arquivo_miniatura);
} elseif ($ext == "jpg") {
imagejpeg($img_final, $arquivo_miniatura);
} elseif ($ext == "gif") {
imagegif($img_final, $arquivo_miniatura);
}
// a memória usada para tudo isso é liberada.
ImageDestroy($img_origem);
ImageDestroy($img_final);
return true;
}
示例12: jResize2
function jResize2($tmp, $name)
{
copy($_FILES, "Photos/" . $_FILES["userfile"]["name"]);
$width = 500;
//*** Fix Width & Heigh (Autu caculate) ***//
$size = GetimageSize($tmp);
$height = round($width * $size[1] / $size[0]);
$images_orig = ImageCreateFromJPEG($tmp);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
ImageJPEG($images_fin, "Photos/" . $name);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
示例13: conv_img
function conv_img($src, $dest, $quality, $imgcut) {
if (file_exists($src) && isset($dest)) {
// path info
$destInfo = pathInfo($dest);
// image src size
$srcSize = getImageSize($src);
$maxWidth=$srcSize[0];
$maxHeight=$srcSize[1];
// image dest size $destSize[0] = width, $destSize[1] = height
$srcRatio= $srcSize[0]/$srcSize[1];
//$destRatio = $maxWidth/$maxHeight;
$RatioX = $maxWidth/$srcSize[0]; // 최대 이미지 너비 / 원본 이미지 너비
$RatioY = $maxHeight/$srcSize[1]; // 최대 이미지 높이 / 원본 이미지 높이
if ($imgcut == N){ //원본 이미지를 자르지 않고 비율대로 축소 할 경우
//if ($destRatio > $srcRatio){
if ($RatioX <= $RatioY) {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth/$srcRatio;
} else {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight*$srcRatio;
}
} else { //원본이미지를 비율대로 축소하고 사이즈에 맞게 자를 경우
//if ($destRatio < $srcRatio){
if ($RatioX <= $RatioY) {
$destSize[0] = round(($srcSize[0]*$maxHeight)/$srcSize[1]); //$maxHeight*$srcRatio;
$destSize[1] = $maxHeight;
$offsetX = round(($destSize[0] - $maxWidth) / 2); // 각각 좌우로 잘라낼 길이
$offsetY = 0;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = round(($srcSize[1]*$maxWidth)/$srcSize[0]); //$maxWidth/$srcRatio;
$offsetX = 0;
$offsetY = round(($destSize[1] - $maxHeight ) / 2); // 각각 상하로 잘라낼 길이
}
}
// path rectification
if ($destInfo['extension'] == "gif"){
$dest = substr_replace($dest, 'jpg', -3);
}
// 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;
}
// true color image, with anti-aliasing
if ($imgcut == N){
$destImage = imageCreateTrueColor($destSize[0], $destSize[1]);
} else {
$destImage = imageCreateTrueColor($maxWidth, $maxHeight);
}
imageAntiAlias($destImage,true);
// resampling
if ($imgcut == N){
imageCopyResampled($destImage, $srcImage,0,0,0,0,$destSize[0],$destSize[1],$srcSize[0],$srcSize[1]);
}else{
imageCopyResampled($destImage, $srcImage, 0, 0, $offsetX, $offsetY, $destSize[0], $destSize[1], ImagesX($srcImage)-$offsetX, ImagesY($srcImage)-$offsetY);
}
// generating image
switch ($srcSize[2]){
case 1:
imageGif($destImage,$dest);
break;
case 2:
imageJpeg($destImage,$dest,$quality);
break;
case 3:
imagePng($destImage,$dest);
break;
}
return true;
//.........这里部分代码省略.........
示例14: roundCornersGD
/**
* Закругленные углы
*
* @param mixed $img дескриптор изображения
* @param mixed $cornercolor цвет углов в 16-ной кодировке. Если false - прозрачный
* @param mixed $radius радиус закругления
* @param mixed $rate сглаживание закругления, максимум - 20
*/
private function roundCornersGD(&$img, $cornercolor, $radius = 5, $rate = 5)
{
if ($radius <= 0) {
return false;
}
if ($rate <= 0) {
$rate = 5;
}
if ($radius > 100) {
$radius = 100;
}
if ($rate > 20) {
$rate = 20;
}
$width = ImagesX($img);
$height = ImagesY($img);
$radius = $width <= $height ? round($width / 100 * $radius / 2) : round($height / 100 * $radius / 2);
$rs_radius = $radius * $rate;
$rs_size = $rs_radius * 2;
ImageAlphablending($img, false);
ImageSaveAlpha($img, true);
$corner = ImageCreateTrueColor($rs_size, $rs_size);
ImageAlphablending($corner, false);
if ($cornercolor === false) {
$this->oImg['type'] = IMAGETYPE_PNG;
}
if ($this->oImg['type'] == IMAGETYPE_PNG) {
$trans = ImageColorAllocateAlpha($corner, 255, 255, 255, 127);
} else {
$trans = ImageColorAllocateAlpha($corner, (int) ($cornercolor % 0x1000000 / 0x10000), (int) ($cornercolor % 0x10000 / 0x100), $cornercolor % 0x100, 0);
}
imagefilledrectangle($corner, 0, 0, $rs_size, $rs_size, $trans);
$positions = array(array(0, 0, 0, 0), array($rs_radius, 0, $width - $radius, 0), array($rs_radius, $rs_radius, $width - $radius, $height - $radius), array(0, $rs_radius, 0, $height - $radius));
foreach ($positions as $pos) {
ImageCopyResampled($corner, $img, $pos[0], $pos[1], $pos[2], $pos[3], $rs_radius, $rs_radius, $radius, $radius);
}
$lx = $ly = 0;
$i = -$rs_radius;
$y2 = -$i;
$r_2 = $rs_radius * $rs_radius;
for (; $i <= $y2; $i++) {
$y = $i;
$x = sqrt($r_2 - $y * $y);
$y += $rs_radius;
$x += $rs_radius;
ImageLine($corner, $x, $y, $rs_size, $y, $trans);
ImageLine($corner, 0, $y, $rs_size - $x, $y, $trans);
$lx = $x;
$ly = $y;
}
foreach ($positions as $i => $pos) {
ImageCopyResampled($img, $corner, $pos[2], $pos[3], $pos[0], $pos[1], $radius, $radius, $rs_radius, $rs_radius);
}
ImageDestroy($corner);
}
示例15: compressedFotoBeritaUmum
public static function compressedFotoBeritaUmum($img)
{
$imageFileType = explode('.', $img);
$imageFileType = $imageFileType[1];
$targetFile = '../../../View/img/Upload/beritaUmum/' . $img;
$tempImg = '../../../View/img/Upload/beritaUmum/_' . $img;
$finalImg = 'http://localhost/SIMasjid/View/img/Upload/beritaUmum/_' . $img;
if (file_exists($tempImg)) {
unlink($tempImg);
}
if (!file_exists($tempImg)) {
if (copy($targetFile, $tempImg)) {
$size = GetimageSize($tempImg);
$width = 1000;
$height = round($width * $size[1] / $size[0]);
if ($imageFileType == 'JPEG' || $imageFileType == 'jpeg' || $imageFileType == 'JPG' || $imageFileType == 'jpg') {
$images_orig = ImageCreateFromJPEG($tempImg);
} else {
if ($imageFileType == 'PNG' || $imageFileType == 'png') {
$images_orig = imagecreatefrompng($tempImg);
} else {
if ($imageFileType == 'GIF' || $imageFileType == 'gif') {
$images_orig = imagecreatefromgif($tempImg);
} else {
if ($imageFileType == 'BMP' || $imageFileType == 'bmp') {
$images_orig = imagecreatefromwbmp($tempImg);
}
}
}
}
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
if ($imageFileType == 'PNG' || $imageFileType == 'png') {
imagealphablending($images_fin, false);
imagesavealpha($images_fin, true);
$transparent = imagecolorallocatealpha($images_fin, 255, 255, 255, 127);
imagefilledrectangle($images_fin, 0, 0, $w, $h, $transparent);
}
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
if ($imageFileType == 'JPEG' || $imageFileType == 'jpeg' || $imageFileType == 'JPG' || $imageFileType == 'jpg') {
ImageJPEG($images_fin, $tempImg);
} else {
if ($imageFileType == 'PNG' || $imageFileType == 'png') {
imagepng($images_fin, $tempImg);
} else {
if ($imageFileType == 'GIF' || $imageFileType == 'gif') {
imagegif($images_fin, $tempImg);
} else {
if ($imageFileType == 'BMP' || $imageFileType == 'bmp') {
imagewbmp($images_fin, $tempImg);
}
}
}
}
ImageDestroy($images_orig);
ImageDestroy($images_fin);
} else {
$finalImg = null;
}
unlink($targetFile);
}
return $finalImg;
}