agid])) {
foreach ($g_flag_thread[$flagid] as &$val) {
flag_thread_filter($val);
}
flag_thread_set($flagid, $g_flag_thread[$flagid]);
}
}
return $g_flag_thread[$flagid];
}
// 设置缓存 $key = flagid / $val = flagid下tid数组
function flag_thread_set($key, $val)
{
global $g_flag_thread;
FALSE === $g_flag_thread and $g_flag_thread = website_get('flag_thread');
empty($g_flag_thread) and $g_flag_thread = array();
$g_flag_thread[$key] = $val;
return website_set('flag_thread', $g_flag_thread);
}
// 删除flag下tid缓存
function flag_thread_delete_cache($flagid)
{
global $g_flag_thread;
FALSE === $g_flag_thread and $g_flag_thread = website_get('flag_thread');
empty($g_flag_thread) and $g_flag_thread = array();
if (isset($g_flag_thread[$flagid])) {
unset($g_flag_thread[$flagid]);
website_set('flag_thread', $g_flag_thread);
}
return TRUE;
}
// Delete by tid / 通过tid删除flag下的主题和对应flagid缓存
function flag_thread_delete_by_tid($tid)
{
global $g_flag_thread;
FALSE === $g_flag_thread and $g_flag_thread = website_get('flag_thread');
if (empty($g_flag_thread)) {
$g_flag_thread = array();
} else {
$thread = well_thread_read_cache($tid);
$arrlist = flag_thread_find($tid, 1, $thread['flags']);
$flagarr = $ids = array();
foreach ($arrlist as $val) {
$flagarr[] = $val['flagid'];
$ids[] = $val['id'];
if (isset($g_flag_thread[$val['flagid']])) unset($g_flag_thread[$val['flagid']]);
}
website_set('flag_thread', $g_flag_thread);
// 主键更新
flag_update($flagarr, array('count-' => 1));
// 主键删除
flag_thread_delete($ids);
}
return TRUE;
}
// 主键删除 通过$flagid删除flag下的主题和对应flagid缓存
function flag_thread_delete_by_flagid($flagid)
{
global $g_flag_thread;
FALSE === $g_flag_thread and $g_flag_thread = website_get('flag_thread');
$read = flag_read_cache($flagid);
if (empty($read)) return TRUE;
$arrlist = flag_thread_find_by_flagid($flagid, 1, $read['count']);
if (empty($arrlist)) return TRUE;
$flagarr = $ids = array();
$n = 0;
foreach ($arrlist as $val) {
++$n;
$flagarr[] = $val['flagid'];
$ids[] = $val['id'];
if (isset($g_flag_thread[$flagid])) unset($g_flag_thread[$flagid]);
}
website_set('flag_thread', $g_flag_thread);
// 主键更新
flag_update($flagarr, array('count-' => $n));
// 主键删除
$r = flag_thread_delete($ids);
return $r;
}
?>break;
}
$r = array('filesize' => filesize($tmpfile), 'width' => $des_width, 'height' => $des_height);;
copy($tmpfile, $destfile);
is_file($tmpfile) && unlink($tmpfile);
imagedestroy($img_dst);
return $r;
}
/**
* 图片裁切
*
* @param string $sourcefile 原图片路径(绝对路径/abc.jpg)
* @param string $destfile 裁切后生成新名称(绝对路径/rename.jpg)
* @param int $clipx 被裁切图片的X坐标
* @param int $clipy 被裁切图片的Y坐标
* @param int $clipwidth 被裁区域的宽度
* @param int $clipheight 被裁区域的高度
* image_clip('xxx/x.jpg', 'xxx/newx.jpg', 10, 40, 150, 150)
*/
function well_image_clip($sourcefile, $destfile, $clipx, $clipy, $clipwidth, $clipheight, $getimgsize = '')
{
global $conf;
empty($getimgsize) AND $getimgsize = getimagesize($sourcefile);
if (empty($getimgsize)) {
return 0;
} else {
$imgwidth = $getimgsize[0];
$imgheight = $getimgsize[1];
if (0 == $imgwidth || 0 == $imgheight) {
return 0;
}
}
if (!function_exists('imagecreatefromjpeg')) {
copy($sourcefile, $destfile);
return filesize($destfile);
}
switch ($getimgsize[2]) {
case 1 :
$imgcolor = imagecreatefromgif($sourcefile);
break;
case 2 :
$imgcolor = imagecreatefromjpeg($sourcefile);
break;
case 3 :
$imgcolor = imagecreatefrompng($sourcefile);
break;
case 15: // WBMP
$imgcolor = imagecreatefromwbmp($sourcefile);
break;
case 18: // WEBP
$imgcolor = imagecreatefromwebp($sourcefile);
break;
}
if (!$imgcolor) return 0;
$img_dst = imagecreatetruecolor($clipwidth, $clipheight);
imagefill($img_dst, 0, 0, 0xFFFFFF);
imagecopyresampled($img_dst, $imgcolor, 0, 0, $clipx, $clipy, $imgwidth, $imgheight, $imgwidth, $imgheight);
$tmppath = isset($conf['tmp_path']) ? $conf['tmp_path'] : ini_get('upload_tmp_dir') . '/';
'/' == $tmppath AND $tmppath = './tmp/';
$tmpfile = $tmppath . md5($destfile) . '.tmp';
imagejpeg($img_dst, $tmpfile, 75);
$n = filesize($tmpfile);
copy($tmpfile, $destfile);
is_file($tmpfile) && unlink($tmpfile);
return $n;
}
function well_image_ext($filename) {
return strtolower(substr(strrchr($filename, '.'), 1));
}
?>
java后端判断图片尺寸(GB,MB,KB形式),图片色彩(黑白照或彩色照片),图片构图(横图竖图方图)-软件玩家 - 软件改变生活!
java后端判断图片尺寸(GB,MB,KB形式),图片色彩(黑白照或彩色照片),图片构图(横图竖图方图)
1.判断图片尺寸,将字节大小转为GB,MB,KB形式
参数size-->File类的getsize()可以获取到文件的字节大小。
2.判断图片构图(横图竖图方图全景图(长大于宽的2.5倍为全景图比例))
3.判断图片色彩,黑白图(灰色图片)或者彩图
本文标签:
java后端判断图片尺寸(GBMBKB形式),图片色彩(黑白照或彩色照片),图片构图(横图竖图方图)
更多相关文章
linux和windows精简版,win7 64/86 超级精简版877MB -三蛋作品
A,基于Win7 SP1 Professional 64位专业版,集成至2018-06安全和质量更新总汇;Internet Explorer 11 浏览器 B,集成.NET
极简板Windows7,大小只有239MB?
今天给大家分享一个超级精简的Windows7,它的大小只有239MB,给家里的老电脑安装体验一下也是可以的。 下面是下载链接 百度网盘下载地址 安装方法: 1.硬盘安装 从上面的链接中下载iso镜像文件&am
Correct way to convert size in bytes to KB, MB, GB in JavaScript - Stack Overflow
I got this code to covert size in bytes via PHP.Now I want to convert those sizes to human readable siz
笔记本电脑连接WIFI速度很慢-解决办法亲测有效【5MBS直达10MBS】
电脑连接WIFI 经常发生连续断网,或者家里的网明明是100M 但是连接电脑WIFI 却连50M都不到。 于是在网上查了很多资料,网上大多的方法 我讲两个: 一.用电脑管
安装Win7分区时多了个128Mb的MSR分区
安装Win7,自定义安装分区时,发现多了个128M的MSR分区,这时不管,继续安装,安装完成后激活系统时,分
javascript - Fabric.js Inline Image Cropping Using Control Dots (mt, mb, mr, ml) - Stack Overflow
I am working with Fabric.js and need to implement inline image cropping using control dots (mt, mb, mr,
发表评论