not-lain / loadimg

a python package for loading images
Apache License 2.0
17 stars 4 forks source link

docstring, readme update and refractoring #3

Closed Saptarshi-Bandopadhyay closed 2 months ago

Saptarshi-Bandopadhyay commented 2 months ago

πŸ“ Provide a description of the new feature

  1. Current docstring for the load_img function states - "takes an input image of type any and returns a pillow image", should it be updated to "takes an input image of type any and returns an image in any one of the specified output types"?
  2. Meanwhile the docstring for the load function states - "loads the img", which could be updated to "loads the image and returns a pillow image".
  3.  def load_img(
        img: Union[str, bytes, np.ndarray, Image.Image],
        output_type: Literal["pil", "numpy", "str", "base64"] = "pil",
      ) -> Any:

    Can this be refractored to -

    def load_img(
        img: SUPPORTED_INPUT_TYPES,
        output_type: SUPPORTED_OUTPUT_TYPES = "pil",
    ) -> Any:
  4. Readme could be updated with 'base64' as one of the supported types.

If any of these updates seem of importance, I can make a PR on the same ☺️

βž• Additional Information

No response

not-lain commented 2 months ago

all of these are interesting. if you are free, let me know which of these you would like to take.

as for point 3 you can leave it to me because I have an Idea of how to to fix that. the fix I have in mind , keep this :

 def load_img(
    img: Union[str, bytes, np.ndarray, Image.Image],
    output_type: Literal["pil", "numpy", "str", "base64"] = "pil",
  ) -> Any:

update the exception message to use inspect to capture all of the supported input types and values and remove the SUPPORTED_INPUT_TYPES and the SUPPORTED_OUTPUT_TYPES from the code.

Saptarshi-Bandopadhyay commented 2 months ago

Sure, I'll leave point 3 to you and make a PR for the rest.

not-lain commented 2 months ago

I will open a separate issue for 3, once done I will release the new version, thanks a lot for the help with this package !