本文整理汇总了PHP中get_img_size_format函数的典型用法代码示例。如果您正苦于以下问题:PHP get_img_size_format函数的具体用法?PHP get_img_size_format怎么用?PHP get_img_size_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_img_size_format函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_thumbnail
function create_thumbnail($source, $new_file, $mimetype)
{
global $attach_config, $imagick;
$source = amod_realpath($source);
$min_filesize = intval($attach_config['img_min_thumb_filesize']);
$img_filesize = @file_exists(@amod_realpath($source)) ? filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return FALSE;
}
$size = image_getdimension($source);
if ($size[0] == 0 && $size[1] == 0) {
return FALSE;
}
$new_size = get_img_size_format($size[0], $size[1]);
$tmp_path = '';
$old_file = '';
if (intval($attach_config['allow_ftp_upload'])) {
$old_file = $new_file;
$tmp_path = explode('/', $source);
$tmp_path[count($tmp_path) - 1] = '';
$tmp_path = implode('/', $tmp_path);
if ($tmp_path == '') {
$tmp_path = '/tmp';
}
$value = trim($tmp_path);
if ($value[strlen($value) - 1] == '/') {
$value[strlen($value) - 1] = ' ';
}
$new_file = trim($value) . '/t00000';
}
$used_imagick = FALSE;
if (is_imagick()) {
if (is_array($size) && count($size) > 0) {
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
if (@file_exists(@amod_realpath($new_file))) {
$used_imagick = TRUE;
}
}
}
if (!$used_imagick) {
$type = $size[2];
$supported_types = get_supported_image_types();
if (in_array($type, $supported_types)) {
switch ($type) {
case '1':
$im = imagecreatefromgif($source);
$new_im = imagecreate($new_size[0], $new_size[1]);
imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
imagegif($new_im, $new_file);
break;
case '2':
$im = imagecreatefromjpeg($source);
$new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]);
imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
imagejpeg($new_im, $new_file, 90);
break;
case '3':
$im = imagecreatefrompng($source);
$new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]);
imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
imagepng($new_im, $new_file);
break;
}
}
}
if (!@file_exists(@amod_realpath($new_file))) {
return FALSE;
}
if (intval($attach_config['allow_ftp_upload'])) {
$result = ftp_file($new_file, $old_file, $this->type, TRUE);
// True for disable error-mode
if (!$result) {
return FALSE;
}
} else {
@chmod($new_file, 0664);
}
return TRUE;
}
示例2: create_thumbnail
/**
* Create Thumbnail
*/
function create_thumbnail($source, $destination, $mimetype)
{
global $config, $phpbb_filesystem;
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = file_exists($source) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
$dimension = @getimagesize($source);
if ($dimension === false) {
return false;
}
list($width, $height, $type, ) = $dimension;
if (empty($width) || empty($height)) {
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
// Do not create a thumbnail if the resulting width/height is bigger than the original one
if ($new_width >= $width && $new_height >= $height) {
return false;
}
$used_imagick = false;
// Only use imagemagick if defined and the passthru function not disabled
if ($config['img_imagick'] && function_exists('passthru')) {
if (substr($config['img_imagick'], -1) !== '/') {
$config['img_imagick'] .= '/';
}
@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . (defined('PHP_OS') && preg_match('#^win#i', PHP_OS) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
if (file_exists($destination)) {
$used_imagick = true;
}
}
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd']) {
// If the type is not supported, we are not able to create a thumbnail
if ($type['format'] === false) {
return false;
}
switch ($type['format']) {
case IMG_GIF:
$image = @imagecreatefromgif($source);
break;
case IMG_JPG:
@ini_set('gd.jpeg_ignore_warning', 1);
$image = @imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = @imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = @imagecreatefromwbmp($source);
break;
}
if (empty($image)) {
return false;
}
if ($type['version'] == 1) {
$new_image = imagecreate($new_width, $new_height);
if ($new_image === false) {
return false;
}
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
} else {
$new_image = imagecreatetruecolor($new_width, $new_height);
if ($new_image === false) {
return false;
}
// Preserve alpha transparency (png for example)
@imagealphablending($new_image, false);
@imagesavealpha($new_image, true);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
// If we are in safe mode create the destination file prior to using the gd functions to circumvent a PHP bug
if (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') {
@touch($destination);
}
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $destination);
break;
case IMG_JPG:
imagejpeg($new_image, $destination, 90);
break;
case IMG_PNG:
imagepng($new_image, $destination);
break;
case IMG_WBMP:
imagewbmp($new_image, $destination);
break;
}
imagedestroy($new_image);
} else {
return false;
}
}
if (!file_exists($destination)) {
//.........这里部分代码省略.........
示例3: create_thumbnail
function create_thumbnail($source, $destination, $mimetype)
{
global $config;
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = file_exists($source) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
list($width, $height, $type, ) = getimagesize($source);
if (!$width || !$height) {
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
if ($width < $new_width && $height < $new_height) {
return false;
}
$used_imagick = false;
if (file_exists($destination)) {
passthru($config['img_imagick'] . 'convert' . (defined('PHP_OS') && preg_match('#win#i', PHP_OS) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $destination) . '"');
if (file_exists($new_file)) {
$used_imagick = true;
}
}
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd']) {
switch ($type['format']) {
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
case IMG_JPG:
$image = imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = imagecreatefromwbmp($source);
break;
}
if ($type['version'] == 1) {
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
} else {
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $destination);
break;
case IMG_JPG:
imagejpeg($new_image, $destination, 90);
break;
case IMG_PNG:
imagepng($new_image, $destination);
break;
case IMG_WBMP:
imagewbmp($new_image, $destination);
break;
}
imagedestroy($new_image);
}
}
if (!file_exists($destination)) {
return false;
}
@chmod($destination, 0666);
return true;
}
示例4: create_thumbnail
/**
* Create thumbnail
*/
function create_thumbnail($source, $new_file, $mimetype)
{
global $attach_config, $imagick;
$source = amod_realpath($source);
$min_filesize = (int) $attach_config['img_min_thumb_filesize'];
$img_filesize = @file_exists($source) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
list($width, $height, $type, ) = getimagesize($source);
if (!$width || !$height) {
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
$tmp_path = $old_file = '';
if (intval($attach_config['allow_ftp_upload'])) {
$old_file = $new_file;
$tmp_path = explode('/', $source);
$tmp_path[count($tmp_path) - 1] = '';
$tmp_path = implode('/', $tmp_path);
if ($tmp_path == '') {
$tmp_path = '/tmp';
}
$value = trim($tmp_path);
if ($value[strlen($value) - 1] == '/') {
$value[strlen($value) - 1] = ' ';
}
//
$new_file = tempnam(trim($value), 't00000');
// We remove it now because it gets created again later
@unlink($new_file);
}
$used_imagick = false;
if (is_imagick()) {
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
if (@file_exists($new_file)) {
$used_imagick = true;
}
}
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd']) {
switch ($type['format']) {
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
case IMG_JPG:
$image = imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = imagecreatefromwbmp($source);
break;
}
if ($type['version'] == 1 || !$attach_config['use_gd2']) {
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
} else {
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $new_file);
break;
case IMG_JPG:
imagejpeg($new_image, $new_file, 90);
break;
case IMG_PNG:
imagepng($new_image, $new_file);
break;
case IMG_WBMP:
imagewbmp($new_image, $new_file);
break;
}
imagedestroy($new_image);
}
}
if (!@file_exists($new_file)) {
return false;
}
if (intval($attach_config['allow_ftp_upload'])) {
$result = ftp_file($new_file, $old_file, $mimetype, true);
// True for disable error-mode
@unlink($new_file);
if (!$result) {
return false;
}
} else {
@chmod($new_file, 0664);
}
return true;
}
示例5: create_thumbnail
/**
* Create thumbnail
*/
function create_thumbnail($source, $new_file, $mimetype)
{
global $attach_config, $imagick;
$source = amod_realpath($source);
$min_filesize = (int) $attach_config['img_min_thumb_filesize'];
$img_filesize = @file_exists($source) ? @filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return false;
}
list($width, $height, $type, ) = getimagesize($source);
if (!$width || !$height) {
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
$tmp_path = $old_file = '';
$used_imagick = false;
if (is_imagick()) {
passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
if (@file_exists($new_file)) {
$used_imagick = true;
}
}
if (!$used_imagick) {
$type = get_supported_image_types($type);
if ($type['gd']) {
switch ($type['format']) {
case IMG_GIF:
$image = imagecreatefromgif($source);
break;
case IMG_JPG:
$image = imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = imagecreatefromwbmp($source);
break;
}
if ($type['version'] == 1 || !$attach_config['use_gd2']) {
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
} else {
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $new_file);
break;
case IMG_JPG:
imagejpeg($new_image, $new_file, 90);
break;
case IMG_PNG:
imagepng($new_image, $new_file);
break;
case IMG_WBMP:
imagewbmp($new_image, $new_file);
break;
}
imagedestroy($new_image);
}
}
if (!@file_exists($new_file)) {
return false;
}
@chmod($new_file, 0664);
return true;
}
示例6: create_thumbnail
function create_thumbnail($source, $new_file)
{
global $attach_config;
$source = amod_realpath($source);
$min_filesize = intval($attach_config['img_min_thumb_filesize']);
$img_filesize = file_exists(amod_realpath($source)) ? filesize($source) : false;
if (!$img_filesize || $img_filesize <= $min_filesize) {
return FALSE;
}
$size = image_getdimension($source);
if ($size[0] <= 0 && $size[1] <= 0) {
return FALSE;
}
$new_size = get_img_size_format($size[0], $size[1]);
$tmp_path = '';
$old_file = '';
if (intval($attach_config['allow_ftp_upload'])) {
$old_file = $new_file;
$tmp_path = explode('/', $source);
$tmp_path[count($tmp_path) - 1] = '';
$tmp_path = implode('/', $tmp_path);
if ($tmp_path == '') {
$tmp_path = '/tmp';
}
$value = trim($tmp_path);
if ($value[strlen($value) - 1] == '/') {
$value[strlen($value) - 1] = ' ';
}
$new_file = trim($value) . '/t00000';
}
global $MAIN_CFG;
if (!isset($MAIN_CFG['imaging']['type'])) {
//$attach_config['use_gd2']
$MAIN_CFG['imaging']['type'] = empty($attach_config['img_imagick']) ? 'gd2' : 'im';
$MAIN_CFG['imaging']['impath'] = $attach_config['img_imagick'];
$MAIN_CFG['imaging']['pbmpath'] = $attach_config['img_imagick'];
}
require_once 'includes/imaging/imaging.inc';
Graphic::resize($source, $new_size, $new_file, $size);
if (!file_exists(amod_realpath($new_file))) {
return FALSE;
}
if (intval($attach_config['allow_ftp_upload'])) {
$result = ftp_file($new_file, $old_file, $this->type, TRUE);
// True for disable error-mode
if (!$result) {
return FALSE;
}
} else {
chmod($new_file, PHP_AS_NOBODY ? 0666 : 0644);
}
return TRUE;
}
示例7: create_thumbnail
function create_thumbnail($source, $destination, $mimetype)
{
global $config;
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
$dimension = @getimagesize($source);
if ($dimension === false)
{
return false;
}
list($width, $height, $type, ) = $dimension;
if (empty($width) || empty($height))
{
return false;
}
if ($width <= $config['photo_thumb_width'] && $height <= $config['photo_thumb_height'])
{
return false;
}
list($new_width, $new_height) = get_img_size_format($width, $height);
// Do not create a thumbnail if the resulting width/height is bigger than the original one
if ($new_width > $width && $new_height > $height)
{
return false;
}
$used_imagick = false;
// Only use imagemagick if defined and the passthru function not disabled
if ($config['img_imagick'] && function_exists('passthru'))
{
@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $destination) . '"');
if (file_exists($destination))
{
$used_imagick = true;
}
}
if (!$used_imagick)
{
$type = get_supported_image_types($type);
if ($type['gd'])
{
// If the type is not supported, we are not able to create a thumbnail
if ($type['format'] === false)
{
return false;
}
switch ($type['format'])
{
case IMG_GIF:
$image = @imagecreatefromgif($source);
break;
case IMG_JPG:
$image = @imagecreatefromjpeg($source);
break;
case IMG_PNG:
$image = @imagecreatefrompng($source);
break;
case IMG_WBMP:
$image = @imagecreatefromwbmp($source);
break;
}
if ($type['version'] == 1)
{
$new_image = imagecreate($new_width, $new_height);
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
else
{
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
}
// If we are in safe mode create the destination file prior to using the gd functions to circumvent a PHP bug
if (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on')
{
@touch($destination);
}
switch ($type['format'])
{
case IMG_GIF:
imagegif($new_image, $destination);
break;
//.........这里部分代码省略.........