Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to main #74

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ services:
"*",
]

shm_size: '2gb'

ports:
- ${LISTEN:-80}:8000

Expand Down
12 changes: 5 additions & 7 deletions services/photo_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ async def get_by_id(id: str, *, check_file: bool = True) -> Photo | None:
@staticmethod
@trace
async def upload(node_id: int, user_id: int, file: UploadFile) -> Photo:
photo = Photo(
node_id=node_id,
user_id=user_id,
)

img = Image.open(file.file)
img = ImageOps.exif_transpose(img)
img = _resize_image(img)
img_bytes = _optimize_quality(img)

await photo.file_path.write_bytes(img_bytes)

async with db_write() as session:
photo = Photo(
node_id=node_id,
user_id=user_id,
)
session.add(photo)

await photo.file_path.write_bytes(img_bytes)
return photo


Expand Down