Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
BDE
nk20
Merge requests
!37
always save to png
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
always save to png
fix_picture_upload
into
master
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
Pierre-antoine Comby
requested to merge
fix_picture_upload
into
master
5 years ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
👍
0
👎
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
663ee072
1 commit,
5 years ago
1 file
+
4
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
apps/member/views.py
+
4
−
3
Options
@@ -238,17 +238,18 @@ class ProfilePictureUpdateView(LoginRequiredMixin, FormMixin, DetailView):
h
=
form
.
cleaned_data
[
'
height
'
]
# image crop and resize
image_file
=
io
.
BytesIO
(
image_field
.
read
())
ext
=
image_field
.
name
.
split
(
'
.
'
)[
-
1
]
ext
=
image_field
.
name
.
split
(
'
.
'
)[
-
1
].
lower
()
#TODO: support GIF format
image
=
Image
.
open
(
image_file
)
image
=
image
.
crop
((
x
,
y
,
x
+
w
,
y
+
h
))
image_clean
=
image
.
resize
((
settings
.
PIC_WIDTH
,
settings
.
PIC_RATIO
*
settings
.
PIC_WIDTH
),
Image
.
ANTIALIAS
)
image_file
=
io
.
BytesIO
()
image_clean
.
save
(
image_file
,
ext
)
image_clean
.
save
(
image_file
,
"
PNG
"
)
image_field
.
file
=
image_file
# renaming
filename
=
"
{}_pic.
{}
"
.
format
(
self
.
object
.
note
.
pk
,
ext
)
filename
=
"
{}_pic.
png
"
.
format
(
self
.
object
.
note
.
pk
)
image_field
.
name
=
filename
self
.
object
.
note
.
display_image
=
image_field
self
.
object
.
note
.
save
()
Loading