Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加tiff格式支持&图片管理页面中,psd、tif图片弹窗中显示的图片使用png缩略图 #339

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function output(Request $request, ImageService $service): StreamedRespons
}

// 浏览器无法预览的图片,改为 png 格式输出
if (in_array($image->extension, ['psd', 'tif', 'bmp'])) {
if (in_array($image->extension, ['psd', 'tif', 'tiff', 'bmp'])) {
$mimetype = 'image/png';
$contents = InterventionImage::make($contents)->encode('png')->getEncoded();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Admin/GroupRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function rules()
'configs.limit_per_month' => 'required|integer',
'configs.path_naming_rule' => 'max:400',
'configs.file_naming_rule' => 'max:400',
'configs.accepted_file_suffixes' => 'required|array|in:jpeg,jpg,png,gif,tif,bmp,ico,psd,webp',
'configs.accepted_file_suffixes' => 'required|array|in:jpeg,jpg,png,gif,tif,tiff,bmp,ico,psd,webp',

'configs.is_enable_scan' => 'boolean',
'configs.scanned_action' => [
Expand Down
2 changes: 1 addition & 1 deletion config/convention.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
GroupConfigKey::LimitPerDay => 300,
GroupConfigKey::LimitPerWeek => 600,
GroupConfigKey::LimitPerMonth => 999,
GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'bmp', 'ico', 'psd', 'webp'],
GroupConfigKey::AcceptedFileSuffixes => ['jpeg', 'jpg', 'png', 'gif', 'tif', 'tiff', 'bmp', 'ico', 'psd', 'webp'],
GroupConfigKey::PathNamingRule => '{Y}/{m}/{d}',
GroupConfigKey::FileNamingRule => '{uniqid}',
GroupConfigKey::ImageCacheTtl => 2626560,
Expand Down
32 changes: 30 additions & 2 deletions resources/views/admin/image/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,8 @@ function del(id) {

$('.item').click(function () {
let image = $(this).data('json');
let html = $('#image-tpl').html()
let htm = $('#image-tpl').html()
.replace(/__id__/g, image.id)
.replace(/__url__/g, image.url)
.replace(/__user_name__/g, image.user ? image.user.name+'('+image.user.email+')' : '游客')
.replace(/__user_email__/g, image.user ? image.user.email : '-')
.replace(/__album_name__/g, image.album ? image.album.name : '-')
Expand All @@ -374,10 +373,39 @@ function del(id) {
.replace(/__is_unhealthy__/g, image.is_unhealthy ? '<span class="text-red-500"><i class="fas fa-exclamation-triangle"></i> 是</span>' : '否')
.replace(/__uploaded_ip__/g, image.uploaded_ip)
.replace(/__created_at__/g, image.created_at);
// 检查是否为无法预览的psd,tif图片
let checkstr=image.url;
let check0="psd";
let check1="tif";
let check2="tiff";
if(checkstr.match(check0)){
let html=htm.replace(/__url__/g, "/thumbnails/"+image.md5+".png");

$('#modal-content').html(html);

modal.open('content-modal')
}
else if(checkstr.match(check1)){
let html=htm.replace(/__url__/g, "/thumbnails/"+image.md5+".png");

$('#modal-content').html(html);

modal.open('content-modal')
}
else if(checkstr.match(check2)){
let html=htm.replace(/__url__/g, "/thumbnails/"+image.md5+".png");

$('#modal-content').html(html);

modal.open('content-modal')
}
else{
let html = htm.replace(/__url__/g, image.url);

$('#modal-content').html(html);

modal.open('content-modal')
}
});

$('.item-user').click(function (e) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/upload.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
setStatus(data, UPLOAD_WAITING);
};

if (['psd', 'tif'].indexOf(file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase()) !== -1) {
if (['psd', 'tif', 'tiff'].indexOf(file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase()) !== -1) {
setThumb('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAEDRJREFUeF7tnVmQFdUdxv99t9n3gWHYl0FccJkILjGKGlGUBCNaVMoSNYssVipllYlvqRl88IGq6FOEQcUklahxDVFJFCNqYjSIghqDCgPINsNsd+6du28n1W1QwJm5fU+fc293n6+r5qnP/zvn//vmq5nuPn2vRjhAAATGJKCBDQiAwNgEEBD8doDAOAQQEPx6gAACgt8BEOAjgL8gfNxQpQgBBEQRo9EmHwEEhI8bqhQhgIAoYjTa5COAgPBxQ5UiBBAQRYxGm3wEEBA+bqhShAACoojRaJOPAALCxw1VihBAQBQxGm3yEUBA+LihShECCIgiRqNNPgIICB83VClCAAFRxGi0yUcAAeHjhipFCCAgihiNNvkIICB83FClCAEERBGj0SYfAQSEjxuqFCGAgChiNNrkI4CA8HFDlSIEEBBFjEabfAQQED5uqFKEAAKiiNFok48AAsLHDVWKEEBAFDEabfIRQED4uKFKEQIIiCJGo00+AggIHzdUKUIAAVHEaLTJRwAB4eOGKkUIICCKGI02+QggIHzcUKUIAQREEaPRJh+BogXksU/7a9IB/wrK0qWapl3CiJ3Dt2RUKUlAo93E2Js5ol3erPfl1fNqB4rBoSgB2bA3eKXH41nPGFtYjKYwh+sJHGRED6xtq39EdqfSA9LVPfwsY3Sz7EagryIBbeuatrqlMjuXGpANe4OdmqZ1yGwA2moTYMSWr21reEEWBWkB6fp84GLm8b0ra+HQBYETBDRGbavn1nfLICItIBv2BbdopC2TsWhogsBpBF5Y01a/XAYVKQHpYMzX2h3qJ6J6GYuGJgicRiCsDe9rXr1gQVo0GSkB2dQdWphjbIfoxUIPBMYiwMjznbVttW+LJiQlIA/vDd7j0bSHRC8WeiAwJgHG7l0zt+FB0YSkBAR3r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AQV9mJZkQTQEBEE4WeqwggIK6yE82IJoCAiCYKPVcRQEBcZSeaEU0AARFNFHquIoCAuMpONCOaAAIimij0XEUAAXGVnWhGNAEERDRR6LmKAALiKjvRjGgCCIhootBzFQEExFV2ohnRBBAQ0USh5yoCCIir7EQzogkgIKKJQs9VBBAQV9mJZkQTQEBEE4WeqwggIK6yE82IJoCAiCYKPVcRQEBcZSeaEU3gf3U/xSPf2CxGAAAAAElFTkSuQmCC');
} else {
loadImage(file, function (img) {
Expand Down