-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from ezod/bluesky
Bluesky Conversion
- Loading branch information
Showing
8 changed files
with
107 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
from PIL import Image | ||
|
||
|
||
def resize_and_compress(input_path, output_path, max_size, target_resolution): | ||
with Image.open(input_path) as image: | ||
# resize to target resolution | ||
if image.size[0] > target_resolution[0] or image.size[1] > target_resolution[1]: | ||
image = image.resize(target_resolution, Image.LANCZOS) | ||
|
||
# reduce quality until below maximum size | ||
quality = 95 | ||
while quality > 10: | ||
image.save(output_path, format="JPEG", quality=quality) | ||
if os.path.getsize(output_path) <= max_size: | ||
return True | ||
quality -= 5 | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ name = "aistweet" | |
authors = [ | ||
{name = "Aaron Mavrinac", email = "[email protected]"}, | ||
] | ||
description = "Twitter photo bot for Raspberry Pi AIS tracking stations" | ||
description = "Bluesky photo bot for Raspberry Pi AIS tracking stations" | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
|
Oops, something went wrong.