Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
486c18f6
Unverified
Commit
486c18f6
authored
4 years ago
by
Travis Ralston
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #295 from Sorunome/soru/fix-gif
fix: Some gifs not thumbnailing correctly
parents
d8881dda
82bb3834
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
thumbnailing/i/gif.go
+11
-9
11 additions, 9 deletions
thumbnailing/i/gif.go
with
11 additions
and
9 deletions
thumbnailing/i/gif.go
+
11
−
9
View file @
486c18f6
...
...
@@ -49,15 +49,6 @@ func (d gifGenerator) GenerateThumbnail(b []byte, contentType string, width int,
disposal
=
g
.
Disposal
[
i
]
}
// if disposal type is 1 (preserve previous frame) we can get artifacts from re-scaling.
// as such, we re-render those frames to disposal type 0 (start with a transparent frame)
// see https://www.w3.org/Graphics/GIF/spec-gif89a.txt
if
disposal
==
1
{
g
.
Disposal
[
i
]
=
0
}
else
{
draw
.
Draw
(
frameImg
,
frameImg
.
Bounds
(),
image
.
Transparent
,
image
.
Point
{
X
:
0
,
Y
:
0
},
draw
.
Src
)
}
// Copy the frame to a new image and use that
draw
.
Draw
(
frameImg
,
frameImg
.
Bounds
(),
img
,
image
.
Point
{
X
:
0
,
Y
:
0
},
draw
.
Over
)
...
...
@@ -94,6 +85,17 @@ func (d gifGenerator) GenerateThumbnail(b []byte, contentType string, width int,
},
nil
}
// if disposal type is 0 or 1 (preserve previous frame) we can get artifacts from re-scaling.
// as such, we re-render those frames to disposal type 1 (do not dispose)
// Importantly, we do not clear the previous frame buffer canvas
// see https://www.w3.org/Graphics/GIF/spec-gif89a.txt
// This also applies to frame disposal type 0, https://legacy.imagemagick.org/Usage/anim_basics/#none
if
disposal
==
1
||
disposal
==
0
{
g
.
Disposal
[
i
]
=
1
}
else
{
draw
.
Draw
(
frameImg
,
frameImg
.
Bounds
(),
image
.
Transparent
,
image
.
Point
{
X
:
0
,
Y
:
0
},
draw
.
Src
)
}
g
.
Image
[
i
]
=
targetImg
}
...
...
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