Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Workers
Base Worker
Commits
0380a5e8
Commit
0380a5e8
authored
1 year ago
by
Yoann Schneider
Committed by
Bastien Abadie
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow resizing sub elements
parent
9fbb705a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!396
Allow resizing sub elements
Pipeline
#132102
passed
1 year ago
Stage: test
Stage: build
Stage: release
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/models.py
+1
-15
1 addition, 15 deletions
arkindex_worker/models.py
tests/test_element.py
+1
-1
1 addition, 1 deletion
tests/test_element.py
with
2 additions
and
16 deletions
arkindex_worker/models.py
+
1
−
15
View file @
0380a5e8
...
...
@@ -10,8 +10,6 @@ from typing import Generator, List, Optional
from
PIL
import
Image
from
requests
import
HTTPError
from
arkindex_worker
import
logger
class
MagicDict
(
dict
):
"""
...
...
@@ -172,7 +170,6 @@ class Element(MagicDict):
from
arkindex_worker.image
import
(
download_tiles
,
open_image
,
polygon_bounding_box
,
)
if
not
self
.
get
(
"
zone
"
):
...
...
@@ -187,20 +184,9 @@ class Element(MagicDict):
if
max_width
is
None
and
max_height
is
None
:
resize
=
"
full
"
else
:
bounding_box
=
polygon_bounding_box
(
self
.
zone
.
polygon
)
original_size
=
{
"
w
"
:
self
.
zone
.
image
.
width
,
"
h
"
:
self
.
zone
.
image
.
height
}
# No resizing if the element is smaller than the image.
if
(
bounding_box
.
width
!=
original_size
[
"
w
"
]
or
bounding_box
.
height
!=
original_size
[
"
h
"
]
):
resize
=
"
full
"
logger
.
warning
(
"
Only full image size elements covered,
"
+
"
downloading full size image.
"
)
# No resizing if the image is smaller than the wanted size.
el
if
(
max_width
is
None
or
original_size
[
"
w
"
]
<=
max_width
)
and
(
if
(
max_width
is
None
or
original_size
[
"
w
"
]
<=
max_width
)
and
(
max_height
is
None
or
original_size
[
"
h
"
]
<=
max_height
):
resize
=
"
full
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_element.py
+
1
−
1
View file @
0380a5e8
...
...
@@ -141,7 +141,7 @@ def test_open_image_resize_partial_element(mocker):
assert
elt
.
open_image
(
max_height
=
400
,
use_full_image
=
True
)
==
"
an image!
"
assert
open_mock
.
call_count
==
1
assert
open_mock
.
call_args
==
mocker
.
call
(
"
http://something/full/
full
/0/default.jpg
"
,
"
http://something/full/
,400
/0/default.jpg
"
,
rotation_angle
=
0
,
mirrored
=
False
,
)
...
...
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