修复webp缩略图生成问题 动图不生成
修复普通目录大图地址缺失 修复文件推荐报错
This commit is contained in:
@@ -50,6 +50,7 @@ class image {
|
||||
|
||||
function Thumb($source, $target, $thumbwidth, $thumbheight, $thumbtype = 1, $nosuffix = 0) {
|
||||
$return = $this->init('thumb', $source, $target,$nosuffix);
|
||||
|
||||
if($return <= 0) {
|
||||
return $this->returncode($return);
|
||||
}
|
||||
@@ -275,9 +276,81 @@ class image {
|
||||
}
|
||||
return array($x, $y, $w, $h);
|
||||
}
|
||||
function webpinfo($file) {
|
||||
if (!is_file($file)) {
|
||||
return false;
|
||||
} else {
|
||||
$file = realpath($file);
|
||||
}
|
||||
|
||||
$fp = fopen($file, 'rb');
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = fread($fp, 90);
|
||||
|
||||
fclose($fp);
|
||||
unset($fp);
|
||||
|
||||
$header_format = 'A4Riff/' . // 获取4个字符的字符串
|
||||
'I1Filesize/' . // 获取一个整数(文件大小,但不是实际大小)
|
||||
'A4Webp/' . // 获取4个字符的字符串
|
||||
'A4Vp/' . // 获取4个字符的字符串
|
||||
'A74Chunk'; // 获取74个字符的字符串
|
||||
$header = unpack($header_format, $data);
|
||||
unset($data, $header_format);
|
||||
|
||||
if (!isset($header['Riff']) || strtoupper($header['Riff']) !== 'RIFF') {
|
||||
return false;
|
||||
}
|
||||
if (!isset($header['Webp']) || strtoupper($header['Webp']) !== 'WEBP') {
|
||||
return false;
|
||||
}
|
||||
if (!isset($header['Vp']) || strpos(strtoupper($header['Vp']), 'VP8') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
strpos(strtoupper($header['Chunk']), 'ANIM') !== false ||
|
||||
strpos(strtoupper($header['Chunk']), 'ANMF') !== false
|
||||
) {
|
||||
$header['Animation'] = true;
|
||||
} else {
|
||||
$header['Animation'] = false;
|
||||
}
|
||||
|
||||
if (strpos(strtoupper($header['Chunk']), 'ALPH') !== false) {
|
||||
$header['Alpha'] = true;
|
||||
} else {
|
||||
if (strpos(strtoupper($header['Vp']), 'VP8L') !== false) {
|
||||
// 如果是VP8L,假设该图像会有透明度
|
||||
// 如Google文档中描述的WebP简单文件格式无损部分
|
||||
$header['Alpha'] = true;
|
||||
} else {
|
||||
$header['Alpha'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
unset($header['Chunk']);
|
||||
return $header;
|
||||
}
|
||||
|
||||
function loadsource() {
|
||||
$imagecreatefromfunc = &$this->imagecreatefromfunc;
|
||||
if($imagecreatefromfunc == 'imagecreatefromwebp'){
|
||||
$info = $this->webpinfo($this->source);
|
||||
if ($info !== false) {
|
||||
if ($info['Animation']) {
|
||||
return -1;
|
||||
}
|
||||
if ($info['Alpha']) {
|
||||
return -1;
|
||||
}
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
$im = @$imagecreatefromfunc($this->source);
|
||||
if(!$im) {
|
||||
if(!function_exists('imagecreatefromstring')) {
|
||||
@@ -299,7 +372,6 @@ class image {
|
||||
if(!function_exists('imagecreatetruecolor') || !function_exists('imagecopyresampled') || !function_exists('imagejpeg') || !function_exists('imagecopymerge')) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
$imagefunc = &$this->imagefunc;
|
||||
$attach_photo = $this->loadsource();
|
||||
if($attach_photo < 0) {
|
||||
|
||||
@@ -976,15 +976,16 @@ class io_dzz extends io_api
|
||||
if($extraparams['istmp']){
|
||||
return $thumbpath;
|
||||
}
|
||||
$defaultspace = $_G['setting']['defaultspacesetting'];
|
||||
if($defaultspace['bz'] != 'dzz'){
|
||||
$cloudpath = $defaultspace['bz'].':'.$defaultspace['did'] . ':' .$thumbpath;
|
||||
$return = IO::moveThumbFile($cloudpath,$thumbpath);
|
||||
//$thumbpath = $return;
|
||||
|
||||
}
|
||||
if(isset($return['error'])){
|
||||
return false;
|
||||
if($thumbpath){
|
||||
$defaultspace = $_G['setting']['defaultspacesetting'];
|
||||
if($defaultspace['bz'] != 'dzz'){
|
||||
$cloudpath = $defaultspace['bz'].':'.$defaultspace['did'] . ':' .$thumbpath;
|
||||
$return = IO::moveThumbFile($cloudpath,$thumbpath);
|
||||
//$thumbpath = $return;
|
||||
}
|
||||
if(isset($return['error'])){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $thumbpath;
|
||||
|
||||
@@ -1091,7 +1092,7 @@ class io_dzz extends io_api
|
||||
$extraparams['nomark'] = 1;
|
||||
$thumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, 0, $extraparams);
|
||||
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
|
||||
$thumbpath = $bz.$thumbpath;
|
||||
if($thumbpath)$thumbpath = $bz.$thumbpath;
|
||||
if($thumbpath){
|
||||
$img = IO::getFileUri($thumbpath);
|
||||
if ($returnurl) return $img;
|
||||
@@ -1305,7 +1306,7 @@ class io_dzz extends io_api
|
||||
if(!$thumbpath){
|
||||
$cthumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, $original, $extraparams, $filesize);
|
||||
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
|
||||
$thumbpath = $bz.$cthumbpath;
|
||||
if($cthumbpath)$thumbpath = $bz.$cthumbpath;
|
||||
if($cthumbpath){
|
||||
$cacheid = '';
|
||||
if($data['aid']){
|
||||
@@ -1434,7 +1435,7 @@ class io_dzz extends io_api
|
||||
//创建缩略图
|
||||
$cthumbpath = IO::createThumbByOriginal($filepath, $data, $width, $height, $thumbtype, $original, $extraparams, $filesize);
|
||||
$bz = io_remote::getBzByRemoteid($defaultspace['remoteid']);
|
||||
$thumbpath = $bz.$cthumbpath;
|
||||
if($cthumbpath)$thumbpath = $bz.$cthumbpath;
|
||||
if($cthumbpath){
|
||||
$cacheid = '';
|
||||
if($rdata['aid']){
|
||||
|
||||
@@ -387,6 +387,7 @@ class table_pichome_resources extends dzz_table
|
||||
$smallthumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
||||
'thumbsign' => '0', 'path'=>$resourcesdata['path'],'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
||||
$imgdata['iconimg'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
||||
$imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
||||
}else{
|
||||
|
||||
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||
@@ -474,7 +475,7 @@ class table_pichome_resources extends dzz_table
|
||||
$smallthumbparams = ['rid' => $resourcesdata['rid'], 'hash' => VERHASH, 'download' => $download,
|
||||
'thumbsign' => '0', 'path'=>$resourcesdata['path'],'ext' => $resourcesdata['ext'], 'appid' => $resourcesdata['appid'],'hasthumb'=>$resourcesdata['hasthumb']];
|
||||
$imgdata['iconimg'] = getglobal('siteurl') . 'index.php?mod=io&op=getImg&path=' . Pencode($smallthumbparams, 0, '') . '&' . VERHASH;
|
||||
|
||||
$imgdata['originalimg'] = (!$return) ? false: getglobal('siteurl') . 'index.php?mod=io&op=createThumb&path='.$resourcesdata['dpath'].'&size=large';
|
||||
}else{
|
||||
$thumbdata = C::t('thumb_record')->fetch($resourcesdata['rid']);
|
||||
if ($thumbdata['sstatus']) $imgdata['icondata'] = IO::getFileUri($thumbdata['spath']);
|
||||
@@ -812,7 +813,7 @@ class table_pichome_resources extends dzz_table
|
||||
$setarr = [];
|
||||
$setarr['lastdate'] = TIMESTAMP;
|
||||
//如果当前库有该文件,则使用当前文件
|
||||
if ($rid = DB::result_first("select rid from %t where path = %d and appid = %s ", array('pichome_resources_attr', $aid, $appid))) {
|
||||
if ($rid = DB::result_first("select rid from %t where path = %s and appid = %s ", array('pichome_resources_attr', $aid, $appid))) {
|
||||
$resourcesdata = C::t('pichome_resources')->fetch($rid);
|
||||
$nfids = explode(',', $resourcesdata['fids']);
|
||||
$setarr['rid'] = $rid;
|
||||
@@ -897,7 +898,7 @@ class table_pichome_resources extends dzz_table
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ($rid = DB::result_first("select rid from %t where path = %d ", array('pichome_resources_attr', $aid))) {
|
||||
} elseif ($rid = DB::result_first("select rid from %t where path = %s ", array('pichome_resources_attr', $aid))) {
|
||||
//如果当前库无该文件但其它库有
|
||||
//获取原文件基本数据
|
||||
$resourcesdata = C::t('pichome_resources')->fetch($rid);
|
||||
|
||||
@@ -190,6 +190,7 @@ const Tmpfile_rec = {
|
||||
<el-option label="库" value="1"></el-option>
|
||||
<el-option label="单页" value="2"></el-option>
|
||||
<el-option label="栏目" value="3"></el-option>
|
||||
<el-option label="专辑" value="4"></el-option>
|
||||
</el-select>
|
||||
<template v-if="parseInt(item.data[0].link) == 0">
|
||||
<el-input v-model="item.data[0].linkval"></el-input>
|
||||
@@ -204,7 +205,7 @@ const Tmpfile_rec = {
|
||||
<el-option v-for="item in typecollection.alonepage" :label="item.pagename" :value="item.id" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-else-if="parseInt(item.row.link) == 4">
|
||||
<template v-else-if="parseInt(item.data[0].link) == 4">
|
||||
<el-select v-model="item.data[0].linkval" style="width: 100%">
|
||||
<el-option v-for="item in typecollection.tab" :label="item.name" :value="item.gid" :key="item.gid"></el-option>
|
||||
</el-select>
|
||||
|
||||
@@ -26,7 +26,6 @@ $start = $i * $limit;
|
||||
if ($locked) {
|
||||
exit(json_encode(array('error' => '进程已被锁定请稍后再试')));
|
||||
}
|
||||
|
||||
$imageCacheName = 'PICHOMETHUMBSTATUS';
|
||||
$docCacheName = 'PICHOMEDOCSTATUS';
|
||||
$mediaCacheName = 'PICHOMECONVERTSTATUS';
|
||||
@@ -79,16 +78,18 @@ foreach (DB::fetch_all("select appid,path,`type` from %t where (`type` = %d or `
|
||||
}
|
||||
|
||||
if (empty($appids)) {
|
||||
dzz_process::unlock($processname);
|
||||
exit('success');
|
||||
}
|
||||
|
||||
$datas = DB::fetch_all("select r.rid,r.appid,t.rid,t.sstatus,t.lstatus,t.ltimes,t.stimes,least(t.ltimes,t.stimes) as mintimes
|
||||
$datas = DB::fetch_all("select r.rid,r.appid,t.rid,t.sstatus,t.lstatus,t.ltimes,t.stimes,t.ltimes+t.stimes as mintimes
|
||||
from %t t left join %t r on t.rid = r.rid
|
||||
where (t.sstatus < 1 or t.lstatus < 1) and ((t.ltimes+t.stimes) < %d) and r.isdelete = 0 and r.appid in(%n)
|
||||
where (t.sstatus < 1 or t.lstatus < 1) and ((t.ltimes+t.stimes) < %d) and r.isdelete = 0 and r.appid in(%n)
|
||||
order by mintimes asc,r.dateline asc limit $start,$limit", array('thumb_record', 'pichome_resources', 6, $appids));
|
||||
|
||||
if ($datas) {
|
||||
foreach ($datas as $v) {
|
||||
|
||||
$processname1 = 'PICHOMEGETTHUMB_' . $v['rid'];
|
||||
//dzz_process::unlock($processname1);
|
||||
//如果当前数据是锁定状态则跳过
|
||||
@@ -124,10 +125,14 @@ if ($datas) {
|
||||
dzz_process::unlock($processname1);
|
||||
continue;
|
||||
}
|
||||
|
||||
//调用系统获取缩略图
|
||||
$returnurl = IO::getThumb($v['rid'], $thumbsign, 0, 1, 1);
|
||||
dzz_process::unlock($processname1);
|
||||
try{
|
||||
//调用系统获取缩略图
|
||||
$returnurl = IO::getThumb($v['rid'], $thumbsign, 0, 1, 1);
|
||||
dzz_process::unlock($processname1);
|
||||
}catch (Exception $e){
|
||||
runlog('createThumbError',$e->getMessage()."\t".$v['rid']);
|
||||
dzz_process::unlock($processname1);
|
||||
}
|
||||
//exit('aaaa');
|
||||
|
||||
}
|
||||
@@ -155,6 +160,7 @@ function getDzzExt($ext){
|
||||
}else{
|
||||
$imageext = $gdlimitext;
|
||||
}
|
||||
$imageext[] = 'webp';
|
||||
$mediaext = explode(',',$_G['config']['pichomeconvertext']);
|
||||
if(in_array($ext,$docext)){
|
||||
$type = 'docstatus';
|
||||
|
||||
Reference in New Issue
Block a user