Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
340
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
24
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
48e8ee44
Unverified
Commit
48e8ee44
authored
4 years ago
by
MeiMei
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
WebPのアニメーションが失われるのを修正 Fix #6625 (#6649)
parent
9855405b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/server/proxy/proxy-media.ts
+1
-1
1 addition, 1 deletion
src/server/proxy/proxy-media.ts
src/services/drive/add-file.ts
+35
-12
35 additions, 12 deletions
src/services/drive/add-file.ts
with
36 additions
and
13 deletions
src/server/proxy/proxy-media.ts
+
1
−
1
View file @
48e8ee44
...
...
@@ -21,7 +21,7 @@ export async function proxyMedia(ctx: Koa.Context) {
let
image
:
IImage
;
if
(
'
static
'
in
ctx
.
query
&&
[
'
image/png
'
,
'
image/gif
'
,
'
image/apng
'
,
'
image/vnd.mozilla.apng
'
].
includes
(
mime
))
{
if
(
'
static
'
in
ctx
.
query
&&
[
'
image/png
'
,
'
image/gif
'
,
'
image/apng
'
,
'
image/vnd.mozilla.apng
'
,
'
image/webp
'
].
includes
(
mime
))
{
image
=
await
convertToPng
(
path
,
498
,
280
);
}
else
if
(
'
preview
'
in
ctx
.
query
&&
[
'
image/jpeg
'
,
'
image/png
'
,
'
image/gif
'
,
'
image/apng
'
,
'
image/vnd.mozilla.apng
'
].
includes
(
mime
))
{
image
=
await
convertToJpeg
(
path
,
200
,
200
);
...
...
This diff is collapsed.
Click to expand it.
src/services/drive/add-file.ts
+
35
−
12
View file @
48e8ee44
...
...
@@ -7,7 +7,7 @@ import { deleteFile } from './delete-file';
import
{
fetchMeta
}
from
'
../../misc/fetch-meta
'
;
import
{
GenerateVideoThumbnail
}
from
'
./generate-video-thumbnail
'
;
import
{
driveLogger
}
from
'
./logger
'
;
import
{
IImage
,
convertToJpeg
,
convertToWebp
,
convertToPng
,
convertToPngOrJpeg
}
from
'
./image-processor
'
;
import
{
IImage
,
convert
Sharp
ToJpeg
,
convert
Sharp
ToWebp
,
convert
Sharp
ToPng
,
convert
Sharp
ToPngOrJpeg
}
from
'
./image-processor
'
;
import
{
contentDisposition
}
from
'
../../misc/content-disposition
'
;
import
{
getFileInfo
}
from
'
../../misc/get-file-info
'
;
import
{
DriveFiles
,
DriveFolders
,
Users
,
Instances
,
UserProfiles
}
from
'
../../models
'
;
...
...
@@ -19,6 +19,7 @@ import { genId } from '../../misc/gen-id';
import
{
isDuplicateKeyValueError
}
from
'
../../misc/is-duplicate-key-value-error
'
;
import
*
as
S3
from
'
aws-sdk/clients/s3
'
;
import
{
getS3
}
from
'
./s3
'
;
import
*
as
sharp
from
'
sharp
'
;
const
logger
=
driveLogger
.
createSubLogger
(
'
register
'
,
'
yellow
'
);
...
...
@@ -143,6 +144,34 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
* @param generateWeb Generate webpublic or not
*/
export
async
function
generateAlts
(
path
:
string
,
type
:
string
,
generateWeb
:
boolean
)
{
if
(
type
.
startsWith
(
'
video/
'
))
{
try
{
const
thumbnail
=
await
GenerateVideoThumbnail
(
path
);
return
{
webpublic
:
null
,
thumbnail
};
}
catch
(
e
)
{
logger
.
warn
(
`GenerateVideoThumbnail failed:
${
e
}
`
);
return
{
webpublic
:
null
,
thumbnail
:
null
};
}
}
const
img
=
sharp
(
path
);
const
metadata
=
await
img
.
metadata
();
const
isAnimated
=
metadata
.
pages
&&
metadata
.
pages
>
1
;
// skip animated
if
(
isAnimated
)
{
return
{
webpublic
:
null
,
thumbnail
:
null
};
}
// #region webpublic
let
webpublic
:
IImage
|
null
=
null
;
...
...
@@ -151,11 +180,11 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
try
{
if
([
'
image/jpeg
'
].
includes
(
type
))
{
webpublic
=
await
convertToJpeg
(
path
,
2048
,
2048
);
webpublic
=
await
convert
Sharp
ToJpeg
(
img
,
2048
,
2048
);
}
else
if
([
'
image/webp
'
].
includes
(
type
))
{
webpublic
=
await
convertToWebp
(
path
,
2048
,
2048
);
webpublic
=
await
convert
Sharp
ToWebp
(
img
,
2048
,
2048
);
}
else
if
([
'
image/png
'
].
includes
(
type
))
{
webpublic
=
await
convertToPng
(
path
,
2048
,
2048
);
webpublic
=
await
convert
Sharp
ToPng
(
img
,
2048
,
2048
);
}
else
{
logger
.
debug
(
`web image not created (not an required image)`
);
}
...
...
@@ -172,15 +201,9 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
try
{
if
([
'
image/jpeg
'
,
'
image/webp
'
].
includes
(
type
))
{
thumbnail
=
await
convertToJpeg
(
path
,
498
,
280
);
thumbnail
=
await
convert
Sharp
ToJpeg
(
img
,
498
,
280
);
}
else
if
([
'
image/png
'
].
includes
(
type
))
{
thumbnail
=
await
convertToPngOrJpeg
(
path
,
498
,
280
);
}
else
if
(
type
.
startsWith
(
'
video/
'
))
{
try
{
thumbnail
=
await
GenerateVideoThumbnail
(
path
);
}
catch
(
e
)
{
logger
.
warn
(
`GenerateVideoThumbnail failed:
${
e
}
`
);
}
thumbnail
=
await
convertSharpToPngOrJpeg
(
img
,
498
,
280
);
}
else
{
logger
.
debug
(
`thumbnail not created (not an required file)`
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment