Convert Images¶
Bases: Bolt
__init__(input, output, state, **kwargs)
¶
The ConvertImage
class is designed to convert images from one format to another.
It takes an input folder containing images and an output format as arguments.
The class iterates through each image file in the specified folder and converts it to the desired format.
Additional options like quality and subsampling can be specified for lossy formats like 'JPG'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
BatchInput
|
An instance of the BatchInput class for reading the data. |
required |
output |
BatchOutput
|
An instance of the BatchOutput class for saving the data. |
required |
state |
State
|
An instance of the State class for maintaining the state. |
required |
**kwargs |
Additional keyword arguments. |
{}
|
Using geniusrise to invoke via command line¶
genius ConvertImage rise \
batch \
--bucket my_bucket \
--s3_folder s3/input \
batch \
--bucket my_bucket \
--s3_folder s3/output \
none \
process \
--args input_folder=/path/to/image/folder output_format=PNG quality=95 subsampling=0
Using geniusrise to invoke via YAML file¶
process(output_format, quality=None, subsampling=0)
¶
📖 Convert images in the given input folder to the specified output format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_format |
str
|
The format to convert images to ('PNG' or 'JPG'). |
required |
quality |
Optional[int]
|
The quality of the output image for lossy formats like 'JPG'. Defaults to None. |
None
|
subsampling |
Optional[int]
|
The subsampling factor for JPEG compression. Defaults to 0. |
0
|
This method iterates through each image file in the specified folder, reads the image, and converts it to the specified output format. Additional parameters like quality and subsampling can be set for lossy formats.