#22 add JPEG quality
This commit is contained in:
@@ -42,3 +42,6 @@ Specifies the directory to put taken images in to.
|
||||
### `output_filename_format`
|
||||
Specifies the format of the output filename.
|
||||
> See [Python docs](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes) for reference.
|
||||
|
||||
### `output_jpeg_quality`
|
||||
Specify the quality of JPEG compression, best not to go over 95
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
"output_format": "JPEG",
|
||||
"output_extension": ".jpg",
|
||||
"output_directory": "./images",
|
||||
"output_filename_format": "%d-%m-%Y %H-%M-%S"
|
||||
"output_filename_format": "%d-%m-%Y %H-%M-%S",
|
||||
"output_jpeg_quality": 90
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ def main() -> None:
|
||||
filename = f'{formatted_filename}{config["output_extension"]}'
|
||||
|
||||
with open(f'{config["output_directory"]}/{filename}', "wb") as output_file:
|
||||
if config['output_format'].lower() == 'jpeg':
|
||||
pil_image.save(output_file, format=config["output_format"], quality=config["output_jpeg_quality"])
|
||||
else
|
||||
pil_image.save(output_file, format=config["output_format"])
|
||||
else:
|
||||
print('Unknown event {}'.format(event))
|
||||
|
||||
Reference in New Issue
Block a user