Skip to content

Commit 4b33cfb

Browse files
committed
Huge metadata during upload
1 parent 9519392 commit 4b33cfb

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[BASIC]
2-
good-names=df,f,e,i,j,k
2+
good-names=df,f,e,i,j,k,im
33

44
bad-functions=
55
apply,

superannotate/db/project_images.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ def upload_image_to_project(
111111
bucket = s3_resource.Bucket(res["bucket"])
112112
key = prefix + f'{img_name}'
113113
try:
114-
print(project["type"])
115-
images = get_image_array_to_upload(
114+
images_array = get_image_array_to_upload(
116115
img, image_quality_in_editor, project["type"]
117116
)
118-
upload_image_array_to_s3(bucket, *images, key)
117+
upload_image_array_to_s3(bucket, *images_array, key)
119118
except Exception as e:
120119
raise SABaseException(0, "Couldn't upload to data server. " + e)
121120

superannotate/db/projects.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,18 @@ def upload_images_from_folder_to_project(
537537

538538

539539
def upload_image_array_to_s3(
540-
bucket, orig_image, lores_image, huge_image, thumbnail_image, key
540+
bucket, size, orig_image, lores_image, huge_image, thumbnail_image, key
541541
):
542542
bucket.put_object(Body=orig_image, Key=key)
543543
bucket.put_object(Body=lores_image, Key=key + '___lores.jpg')
544-
bucket.put_object(Body=huge_image, Key=key + '___huge.jpg')
544+
bucket.put_object(
545+
Body=huge_image,
546+
Key=key + '___huge.jpg',
547+
Metadata={
548+
'height': str(size[1]),
549+
'width': str(size[0])
550+
}
551+
)
545552
bucket.put_object(Body=thumbnail_image, Key=key + '___thumb.jpg')
546553

547554

@@ -600,7 +607,9 @@ def get_image_array_to_upload(
600607
byte_io_huge.seek(0)
601608
byte_io_orig.seek(0)
602609

603-
return byte_io_orig, byte_io_lores, byte_io_huge, byte_io_thumbs
610+
return (
611+
width, height
612+
), byte_io_orig, byte_io_lores, byte_io_huge, byte_io_thumbs
604613

605614

606615
def __upload_images_to_aws_thread(
@@ -643,10 +652,10 @@ def __upload_images_to_aws_thread(
643652
raise SAImageSizeTooLarge(file_size)
644653
with open(path, "rb") as f:
645654
file = io.BytesIO(f.read())
646-
images = get_image_array_to_upload(
655+
images_array = get_image_array_to_upload(
647656
file, image_quality_in_editor, project["type"]
648657
)
649-
upload_image_array_to_s3(bucket, *images, key)
658+
upload_image_array_to_s3(bucket, *images_array, key)
650659
except Exception as e:
651660
logger.warning("Unable to upload image %s. %s", path, e)
652661
couldnt_upload[thread_id].append(path)

0 commit comments

Comments
 (0)