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
8c0285a0
Commit
8c0285a0
authored
1 year ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Fix AdjustProperties
parent
96f60005
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
thumbnailing/thumbnail.go
+1
-2
1 addition, 2 deletions
thumbnailing/thumbnail.go
thumbnailing/u/dimensions.go
+1
-3
1 addition, 3 deletions
thumbnailing/u/dimensions.go
with
2 additions
and
5 deletions
thumbnailing/thumbnail.go
+
1
−
2
View file @
8c0285a0
...
...
@@ -50,9 +50,8 @@ func GenerateThumbnail(imgStream io.ReadCloser, contentType string, width int, h
return
nil
,
common
.
ErrMediaTooLarge
}
// TODO: Why does AdjustProperties even take `canAnimate` if it's always been hardcoded to `false`? (see git blame on this comment)
var
shouldThumbnail
bool
shouldThumbnail
,
width
,
height
,
_
,
method
=
u
.
AdjustProperties
(
w
,
h
,
width
,
height
,
animated
,
false
,
method
)
shouldThumbnail
,
width
,
height
,
_
,
method
=
u
.
AdjustProperties
(
w
,
h
,
width
,
height
,
animated
,
method
)
if
!
shouldThumbnail
&&
dimensional
{
return
nil
,
common
.
ErrMediaDimensionsTooSmall
}
...
...
This diff is collapsed.
Click to expand it.
thumbnailing/u/dimensions.go
+
1
−
3
View file @
8c0285a0
package
u
func
AdjustProperties
(
srcWidth
int
,
srcHeight
int
,
desiredWidth
int
,
desiredHeight
int
,
wantAnimated
bool
,
canAnimate
bool
,
method
string
)
(
bool
,
int
,
int
,
bool
,
string
)
{
func
AdjustProperties
(
srcWidth
int
,
srcHeight
int
,
desiredWidth
int
,
desiredHeight
int
,
wantAnimated
bool
,
method
string
)
(
bool
,
int
,
int
,
bool
,
string
)
{
aspectRatio
:=
float32
(
srcHeight
)
/
float32
(
srcWidth
)
targetAspectRatio
:=
float32
(
desiredHeight
)
/
float32
(
desiredWidth
)
if
aspectRatio
==
targetAspectRatio
{
...
...
@@ -11,8 +11,6 @@ func AdjustProperties(srcWidth int, srcHeight int, desiredWidth int, desiredHeig
if
srcWidth
<=
desiredWidth
&&
srcHeight
<=
desiredHeight
{
if
wantAnimated
{
return
true
,
srcWidth
,
srcHeight
,
true
,
method
}
else
if
canAnimate
{
return
true
,
srcWidth
,
srcHeight
,
false
,
method
}
else
{
return
false
,
desiredWidth
,
desiredHeight
,
false
,
method
}
...
...
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