Skip to content

Commit

Permalink
Merge pull request #16 from mano8/master
Browse files Browse the repository at this point in the history
README.md and Doc String's improvements
  • Loading branch information
mano8 committed Aug 31, 2023
2 parents deb1e00 + 60f470e commit edd9081
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The package provides versatile resizing options, including:

- fixed_width: Resizing images to an exact width in pixels.
- fixed_height: Resizing images to an exact height in pixels.
- fixed_size: Resizing images based on the first limitation reached (height or width).
- fixed_size: Resizing images based on the highest limitation reached (height or width).
- fixed_width and fixed_height: Resizing images based on the highest limitation reached,
while allowing different height and width values.

Expand Down Expand Up @@ -278,9 +278,9 @@ progressive encoding, and optimization:
<p>recien_llegado_1200x762.jpg by <a href="https://www.ichingmaestrodelosespiritus.com/">@Cezar yañez</a></p>
</div>

#License
# License
This project is licensed under the Apache 2 License - see the [LICENSE](https://github.com/mano8/imgtools_m8/blob/main/LICENCE) file for details.

Authors
# Authors
- [Eli Serra](https://github.com/mano8)
- pre-trained models by [Xavier Weber](https://towardsdatascience.com/deep-learning-based-super-resolution-with-opencv-4fd736678066).
50 changes: 48 additions & 2 deletions imgtools_m8/img_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,28 @@ def resize_image_if_needed(self,
def loop_on_upscale_stats(self,
upscale_stats: dict
):
""""""
"""
Loop through the upscale statistics.
:param upscale_stats: The upscale statistics dictionary.
:type upscale_stats: dict
:yield: A tuple containing:
- The key of the upscale.
- The output format configuration dictionary.
- The scale factor.
- The number of times the upscale is performed.
Example:
>>> upscale_stats = {
>>> 'stats': [
>>> {'key': 0, 'scale': 2, 'nb_upscale': 5},
>>> {'key': 1, 'scale': 3, 'nb_upscale': 7}
>>> ]
>>> }
>>> for key, output_format, scale, nb_upscale in ImageTools.loop_on_upscale_stats(upscale_stats):
>>> print(key, output_format, scale, nb_upscale)
"""
if Ut.is_dict(upscale_stats, not_null=True) \
and Ut.is_list(upscale_stats.get('stats'), not_null=True):
output_formats = self.conf.get_output_formats()
Expand All @@ -444,7 +465,32 @@ def upscale_with_auto_scale(self,
upscale_stats: dict,
file_name: str
) -> bool:
""""""
"""
Upscale the image using the auto scale model.
:param image: The image data as a NumPy ndarray.
:type image: ndarray
:param upscale_stats: The upscale statistics dictionary.
:type upscale_stats: dict
:param file_name: The name of the output file.
:type file_name: str
:return: True if the upscale process is successful, False otherwise.
:rtype: bool
Example:
>>> upscale_stats = {
>>> 'stats': [
>>> {'key': 0, 'scale': 2, 'nb_upscale': 5},
>>> {'key': 1, 'scale': 3, 'nb_upscale': 7}
>>> ]
>>> }
>>> image = ImageTools.read_image("input_image.jpg")
>>> file_name = "output_image"
>>> result = ImageTools.upscale_with_auto_scale(image, upscale_stats, file_name)
>>> print(result)
>>> True
"""
result = False
if image is not None \
and Ut.is_dict(upscale_stats, not_null=True) \
Expand Down

0 comments on commit edd9081

Please sign in to comment.