当前位置: 首页>>代码示例>>PHP>>正文


PHP getimagesize函数代码示例

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


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

示例1: getProperties

 /**
  * Return the file properties of a specific file
  *
  * @param string $filePath
  *
  * @return array
  */
 public function getProperties($filePath)
 {
     $properties = array();
     $info = @getimagesize($filePath);
     $properties['width'] = @$info[0];
     $properties['height'] = @$info[1];
     $properties['type'] = @$info[2];
     $properties['mime'] = @$info['mime'];
     if ($info[0] > 60 || $info[1] > 60) {
         $dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
         $properties['width_60'] = $dimensions[0];
         $properties['height_60'] = $dimensions[1];
     } else {
         $properties['width_60'] = $properties['width'];
         $properties['height_60'] = $properties['height'];
     }
     if ($info[0] > 16 || $info[1] > 16) {
         $dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
         $properties['width_16'] = $dimensions[0];
         $properties['height_16'] = $dimensions[1];
     } else {
         $properties['width_16'] = $properties['width'];
         $properties['height_16'] = $properties['height'];
     }
     return $properties;
 }
开发者ID:dgt41,项目名称:media-manager-improvement,代码行数:33,代码来源:image.php

示例2: getThumbnailDimension

	function getThumbnailDimension($path, $w, $h)
	{
		$dim = array('w' => $w, 'h' => $h);
		if ($w && $h || (!$w && !$h)) return $dim;

		if (@is_readable($path) && function_exists('getimagesize'))
		{
			$info = @getimagesize($path);
			if (!empty($info) && count($info) > 1)
			{
				if (empty($w))
				{
					$w = round($h * $info[0] / $info[1]);
					$dim['w'] = $w;
				}
				else
				{
					$h = round($w * $info[1] / $info[0]);
					$dim['h'] = $h;
				}
			}
		}
		
		return $dim;
	}
开发者ID:xenten,项目名称:swift-kanban,代码行数:25,代码来源:class.ImageHelper.php

示例3: GenerateLogo

	public function GenerateLogo()
	{
		$this->NewLogo($this->FileType); // defaults to png. can use jpg or gif as well

		$this->FontPath = dirname(__FILE__) . '/fonts/';
		$this->ImagePath = dirname(__FILE__) . '/';
		$this->SetBackgroundImage('back.png');
		$size = getimagesize(dirname(__FILE__)."/back.png");
		$imageHeight = $size['1'];

		if(strlen($this->Text[0]) > 0) {
			// AddText() - text, font, fontcolor, fontSize (pt), x, y, center on this width
			$text_position = $this->AddText($this->Text[0], 'xt.otf', 'd0a642', 15, 43, 20);
			$top_right = $text_position['top_right_x'];
		}
		else {
			$top_right = 0;
		}

		if(strlen($this->Text[1]) > 0) {
			// put in our second bit of text
			$text_position2 = $this->AddText($this->Text[1], 'xt.otf', 'ffffff', 45, 5, 46);
			$top_right = max($top_right, $text_position2['top_right_x']);
		}

		if(strlen($this->Text[2]) > 0) {
			// put in our third bit of text
			$text_position3 = $this->AddText($this->Text[2], 'xt.otf', 'b49a5d', 20, 75, 100);
			$top_right = max($top_right, $text_position3['top_right_x']);
		}
		$this->SetImageSize($top_right+20, $imageHeight);
		$this->CropImage = true;

		return $this->MakeLogo();
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:35,代码来源:config.php

示例4: imageDualResize

 function imageDualResize($filename, $cleanFilename, $wtarget, $htarget)
 {
     if (!file_exists($cleanFilename)) {
         $dims = getimagesize($filename);
         $width = $dims[0];
         $height = $dims[1];
         while ($width > $wtarget || $height > $htarget) {
             if ($width > $wtarget) {
                 $percentage = $wtarget / $width;
             }
             if ($height > $htarget) {
                 $percentage = $htarget / $height;
             }
             /*if($width > $height)
             		{
             			$percentage = ($target / $width);
             		}
             		else
             		{
             			$percentage = ($target / $height);
             		}*/
             //gets the new value and applies the percentage, then rounds the value
             $width = round($width * $percentage);
             $height = round($height * $percentage);
         }
         $image = new SimpleImage();
         $image->load($filename);
         $image->resize($width, $height);
         $image->save($cleanFilename);
         $image = null;
     }
     //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
     return "src=\"{$baseurl}/{$cleanFilename}\"";
 }
开发者ID:dave7y,项目名称:thegamesdb,代码行数:34,代码来源:tab_platform-edit.php

示例5: _validate

	protected function _validate($context)
	{
		$config = $this->_config;
		$row = $context->caller;

		if (is_uploaded_file($row->file) && $config->restrict && !in_array($row->extension, $config->ignored_extensions->toArray())) 
		{
			if ($row->isImage()) 
			{
				if (getimagesize($row->file) === false) {
					$context->setError(JText::_('WARNINVALIDIMG'));
					return false;
				}
			}
			else 
			{
				$mime = KFactory::get('com://admin/files.database.row.file')->setData(array('path' => $row->file))->mimetype;

				if ($config->check_mime && $mime) 
				{
					if (in_array($mime, $config->illegal_mimetypes->toArray()) || !in_array($mime, $config->allowed_mimetypes->toArray())) {
						$context->setError(JText::_('WARNINVALIDMIME'));
						return false;
					}
				}
				elseif (!$config->authorized) {
					$context->setError(JText::_('WARNNOTADMIN'));
					return false;
				}
			}
		}
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:32,代码来源:mimetype.php

示例6: title_and_caption_not_utf8

function title_and_caption_not_utf8($meta, $file)
{
    if (!file_exists($file)) {
        return false;
    }
    list(, , $sourceImageType) = getimagesize($file);
    $meta = array();
    if (is_callable('iptcparse')) {
        getimagesize($file, $info);
        if (!empty($info['APP13'])) {
            $iptc = iptcparse($info['APP13']);
            // headline, "A brief synopsis of the caption."
            if (!empty($iptc['2#105'][0])) {
                $meta['title'] = trim($iptc['2#105'][0]);
            } elseif (!empty($iptc['2#005'][0])) {
                $meta['title'] = trim($iptc['2#005'][0]);
            }
            if (!empty($iptc['2#120'][0])) {
                // description / legacy caption
                $caption = trim($iptc['2#120'][0]);
                if (empty($meta['title'])) {
                    // Assume the title is stored in 2:120 if it's short.
                    if (strlen($caption) < 80) {
                        $meta['title'] = $caption;
                    } else {
                        $meta['caption'] = $caption;
                    }
                } elseif ($caption != $meta['title']) {
                    $meta['caption'] = $caption;
                }
            }
        }
    }
    return $meta;
}
开发者ID:ratjadi,项目名称:andreaszeitler.net,代码行数:35,代码来源:functions.php

示例7: _thumb

function _thumb($_filename, $_percent)
{
    //生成png标头文件
    header('Content-type: image/png');
    $_n = explode('.', $_filename);
    //获取文件信息,长和高
    list($_width, $_height) = getimagesize($_filename);
    //生成缩微的长和高
    $_new_width = $_width * $_percent;
    $_new_height = $_height * $_percent;
    //创建一个以0.3百分比新长度的画布
    $_new_image = imagecreatetruecolor($_new_width, $_new_height);
    //按照已有的图片创建一个画布
    switch ($_n[1]) {
        case 'jpg':
            $_image = imagecreatefromjpeg($_filename);
            break;
        case 'png':
            $_image = imagecreatefrompng($_filename);
            break;
        case 'gif':
            $_image = imagecreatefrompng($_filename);
            break;
    }
    //将原图采集后重新复制到新图上,就缩略了
    imagecopyresampled($_new_image, $_image, 0, 0, 0, 0, $_new_width, $_new_height, $_width, $_height);
    imagepng($_new_image);
    imagedestroy($_new_image);
    imagedestroy($_image);
}
开发者ID:zhangshuhui2014,项目名称:foodcool,代码行数:30,代码来源:global.func.php

示例8: Imagem

 /**
  * MÉTODO CONSTRUTOR
  *
  * @author Gibran
  */
 function Imagem($arquivo)
 {
     if (is_file($arquivo)) {
         $this->Arquivo = $arquivo;
         // OBTÉM OS DADOS DA IMAGEM
         $this->ColecaoDados = getimagesize($this->Arquivo);
         // CARREGA A IMAGEM DE ACORDO COM O TIPO
         switch ($this->ColecaoDados[2]) {
             case 1:
                 $this->Recurso = imagecreatefromgif($this->Arquivo);
                 $this->Tipo = "image/gif";
                 break;
             case 2:
                 $this->Recurso = imagecreatefromjpeg($this->Arquivo);
                 $this->Tipo = "image/jpeg";
                 imageinterlace($this->Recurso, true);
                 break;
             case 3:
                 $this->Recurso = imagecreatefrompng($this->Arquivo);
                 $this->Tipo = "image/png";
                 imagealphablending($this->Recurso, false);
                 imagesavealpha($this->Recurso, true);
                 break;
             default:
                 $this->ColecaoDados = null;
                 $this->Recurso = null;
                 $this->Tipo = null;
                 return null;
                 break;
         }
     } else {
         return null;
     }
 }
开发者ID:BGCX067,项目名称:f1n4l-pr0j3c7-f0r-t3h-0n35-wh0-n33d-17-svn-to-git,代码行数:39,代码来源:Imagem.php

示例9: cuttingimg

function cuttingimg($zoom, $fn, $sz)
{
    @mkdir(WUO_ROOT . '/photos/maps');
    $img = imagecreatefrompng(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем идентификатор загруженного изрбражения которое будем резать
    $info = getimagesize(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем в массив информацию об изображении
    $w = $info[0];
    $h = $info[1];
    // ширина и высота исходного изображения
    $sx = round($w / $sz, 0);
    // длинна куска изображения
    $sy = round($h / $sz, 0);
    // высота куска изображения
    $px = 0;
    $py = 0;
    // координаты шага "реза"
    for ($y = 0; $y <= $sz; $y++) {
        for ($x = 0; $x <= $sz; $x++) {
            $imgcropped = imagecreatetruecolor($sx, $sy);
            imagecopy($imgcropped, $img, 0, 0, $px, $py, $sx, $sy);
            imagepng($imgcropped, WUO_ROOT . '/photos/maps/' . $zoom . '-' . $y . '-' . $x . '-' . $fn);
            $px = $px + $sx;
        }
        $px = 0;
        $py = $py + $sy;
    }
}
开发者ID:solodyagin,项目名称:webuseorg3_lite,代码行数:28,代码来源:uploadimageorg.php

示例10: mkthumb

function mkthumb($img_src, $img_width = "100", $img_height = "100", $folder_scr = "include/files", $des_src = "include/files")
{
    // Größe und Typ ermitteln
    list($src_width, $src_height, $src_typ) = getimagesize($folder_scr . "/" . $img_src);
    if (!$src_typ) {
        return false;
    }
    // calculate new size
    if ($src_width >= $src_height) {
        $new_image_height = $src_height / $src_width * $img_width;
        $new_image_width = $img_width;
        if ($new_image_height > $img_height) {
            $new_image_width = $new_image_width / $new_image_height * $img_height;
            $new_image_height = $img_height;
        }
    } else {
        $new_image_width = $src_width / $src_height * $img_height;
        $new_image_height = $img_height;
        if ($new_image_width > $img_width) {
            $new_image_height = $new_image_height / $new_image_width * $img_width;
            $new_image_width = $img_width;
        }
    }
    // for the case that the thumbnail would be bigger then the original picture
    if ($new_image_height > $src_height) {
        $new_image_width = $new_image_width * $src_height / $new_image_height;
        $new_image_height = $src_height;
    }
    if ($new_image_width > $src_width) {
        $new_image_height = $new_image_height * $new_image_width / $src_width;
        $new_image_width = $src_width;
    }
    if ($src_typ == 1) {
        $image = imagecreatefromgif($folder_scr . "/" . $img_src);
        $new_image = imagecreate($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagegif($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 2) {
        $image = imagecreatefromjpeg($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagejpeg($new_image, $des_src . "/" . $img_src . "_thumb", 100);
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } elseif ($src_typ == 3) {
        $image = imagecreatefrompng($folder_scr . "/" . $img_src);
        $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width, $new_image_height, $src_width, $src_height);
        imagepng($new_image, $des_src . "/" . $img_src . "_thumb");
        imagedestroy($image);
        imagedestroy($new_image);
        return true;
    } else {
        return false;
    }
}
开发者ID:GoeGaming,项目名称:bans.sevenelevenclan.org,代码行数:60,代码来源:thumbs.inc.php

示例11: invokeHandler

 protected function invokeHandler()
 {
     $specific = array();
     $size = getimagesize($this->file->getAbsPath());
     if ($size !== false) {
         $specific['imagesize'] = $size[0] . ' x ' . $size[1] . ' px';
     } else {
         $specific['imagesize'] = System::getLanguage()->_('Unknown');
     }
     if (extension_loaded('imagick') && class_exists('Imagick')) {
         try {
             $i = new Imagick($this->file->getAbsPath());
             $specific['format'] = $i->getimageformat();
         } catch (Exception $e) {
             Log::handleException($e, false);
             if ($this->file->ext == "svg") {
                 Log::sysLog('ImageHandler', '"librsvg" is not installed. Without it Imagick could not handle .svg files!');
             }
         }
     } else {
         $specific['format'] = System::getLanguage()->_('Unknown');
     }
     $this->smarty->assign('specific', $specific);
     $this->smarty->display('handler/image.tpl');
 }
开发者ID:nicefirework,项目名称:sharecloud,代码行数:25,代码来源:ImageHandler.class.php

示例12: colorImageBottom

/**
 *  Retourne la couleur du pixel en bas a gauche de l'image
 **/
function colorImageBottom($imageName)
{
    // recuperer le type et la taille de l'image
    // Pb sur certains JPG qui retourne ''
    list($imgW, $imgH, $imgTyp) = getimagesize($imageName);
    switch ($imgTyp) {
        case 1:
            $im = imagecreatefromgif($imageName);
            break;
        case 2:
        case ' ':
            $im = imagecreatefromjpeg($imageName);
            break;
        case 3:
            $im = imagecreatefrompng($imageName);
            break;
        default:
            $app = JFactory::getApplication();
            $app->enqueueMessage(JTEXT::_('IMGNAME_ERROR') . '[name=' . $imageName . '] [ type=' . $imgTyp . '] [ format= ' . $imgW . 'x' . $imgH, 'error');
            var_dump(gd_info());
            return "";
    }
    $rgb = imagecolorat($im, 2, $imgH - 2);
    $hex = sprintf("%06X", $rgb);
    return $hex;
}
开发者ID:sansandeep143,项目名称:av,代码行数:29,代码来源:helper.php

示例13: boot

 public static function boot()
 {
     parent::boot();
     self::saving(function ($download) {
         $fileName = $download->uploadPath(true) . $download->file;
         if (File::isFile($fileName)) {
             $download->file_size = File::size($fileName);
             // Save file size
             try {
                 $imgData = getimagesize($fileName);
                 // Try to gather infos about the image
             } catch (Exception $e) {
             }
             if (isset($imgData[2]) and $imgData[2]) {
                 $download->is_image = true;
                 /*
                  * Create Thumbnail
                  */
                 $size = 50;
                 InterImage::make($fileName)->resize($size, $size, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save($download->uploadPath(true) . $size . '/' . $download->file);
             }
         }
     });
 }
开发者ID:chirilo,项目名称:Contentify,代码行数:26,代码来源:Download.php

示例14: resize

 public static function resize($sourcePath, $destPath, $width, $height, $q = 'JPG', $crop = false)
 {
     try {
         $destDir = dirname($destPath);
         if (!is_dir($destDir)) {
             mkdir($destDir, 0777);
         }
         list($max_width, $max_height) = getimagesize($sourcePath);
         $options = array('correctPermissions' => true, 'resizeUp' => true);
         $thumb = Thumbnailer_ThumbLib::create($sourcePath, $options);
         $width_ratio = $max_width / $width;
         $height_ratio = $max_height / $height;
         if ($max_width < $width or $max_width < $height) {
             if ($width_ratio > $height_ratio) {
                 $thumb->resize(0, $height);
             } else {
                 $thumb->resize($width, 0);
             }
             if ($crop) {
                 $thumb->crop(0, 0, $width, $height);
             }
         } else {
             $thumb->resize($width, $height);
         }
         $thumb->save($destPath, $q);
     } catch (Exception $e) {
         $destPath = $e->getMessage();
     }
     return $destPath;
 }
开发者ID:bklein01,项目名称:SiberianCMS,代码行数:30,代码来源:CreateThumb.php

示例15: fill_watermark

 public function fill_watermark()
 {
     $image = $this->editor->get_image();
     $size = $this->editor->get_size();
     list($mask_width, $mask_height, $mask_type, $mask_attr) = getimagesize($this->args['mask']);
     switch ($mask_type) {
         case 1:
             $mask = imagecreatefromgif($this->args['mask']);
             break;
         case 2:
             $mask = imagecreatefromjpeg($this->args['mask']);
             break;
         case 3:
             $mask = imagecreatefrompng($this->args['mask']);
             break;
     }
     imagealphablending($image, true);
     if (strpos($this->args['position'], 'left') !== false) {
         $left = $this->args['padding'];
     } else {
         $left = $size['width'] - $mask_width - $this->args['padding'];
     }
     if (strpos($this->args['position'], 'top') !== false) {
         $top = $this->args['padding'];
     } else {
         $top = $size['height'] - $mask_height - $this->args['padding'];
     }
     imagecopy($image, $mask, $left, $top, 0, 0, $mask_width, $mask_height);
     $this->editor->update_image($image);
     imagedestroy($mask);
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:31,代码来源:wpthumb.watermark.php


注:本文中的getimagesize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。