diff --git a/.vscode/PythonImportHelper-v2-Completion.json b/.vscode/PythonImportHelper-v2-Completion.json new file mode 100644 index 0000000..8ddecc4 --- /dev/null +++ b/.vscode/PythonImportHelper-v2-Completion.json @@ -0,0 +1,1358 @@ +[ + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageDraw", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageEnhance", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageFilter", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageOps", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageDraw", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageFont", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageOps", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "ImageDraw", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "Image", + "importPath": "PIL", + "description": "PIL", + "isExtraImport": true, + "detail": "PIL", + "documentation": {} + }, + { + "label": "io,", + "kind": 6, + "isExtraImport": true, + "importPath": "io.", + "description": "io.", + "detail": "io.", + "documentation": {} + }, + { + "label": "List", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "List", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "Tuple", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "List", + "importPath": "typing", + "description": "typing", + "isExtraImport": true, + "detail": "typing", + "documentation": {} + }, + { + "label": "io", + "kind": 6, + "isExtraImport": true, + "importPath": "io", + "description": "io", + "detail": "io", + "documentation": {} + }, + { + "label": "StreamingResponse", + "importPath": "fastapi.responses", + "description": "fastapi.responses", + "isExtraImport": true, + "detail": "fastapi.responses", + "documentation": {} + }, + { + "label": "APIRouter", + "importPath": "fastapi", + "description": "fastapi", + "isExtraImport": true, + "detail": "fastapi", + "documentation": {} + }, + { + "label": "UploadFile", + "importPath": "fastapi", + "description": "fastapi", + "isExtraImport": true, + "detail": "fastapi", + "documentation": {} + }, + { + "label": "File", + "importPath": "fastapi", + "description": "fastapi", + "isExtraImport": true, + "detail": "fastapi", + "documentation": {} + }, + { + "label": "Query", + "importPath": "fastapi", + "description": "fastapi", + "isExtraImport": true, + "detail": "fastapi", + "documentation": {} + }, + { + "label": "FastAPI", + "importPath": "fastapi", + "description": "fastapi", + "isExtraImport": true, + "detail": "fastapi", + "documentation": {} + }, + { + "label": "settings", + "importPath": "fastapi_source.core.config", + "description": "fastapi_source.core.config", + "isExtraImport": true, + "detail": "fastapi_source.core.config", + "documentation": {} + }, + { + "label": "settings", + "importPath": "fastapi_source.core.config", + "description": "fastapi_source.core.config", + "isExtraImport": true, + "detail": "fastapi_source.core.config", + "documentation": {} + }, + { + "label": "get_mosaic_image", + "importPath": "fastapi_source.application.ascii.ascii_service", + "description": "fastapi_source.application.ascii.ascii_service", + "isExtraImport": true, + "detail": "fastapi_source.application.ascii.ascii_service", + "documentation": {} + }, + { + "label": "cv2", + "kind": 6, + "isExtraImport": true, + "importPath": "cv2", + "description": "cv2", + "detail": "cv2", + "documentation": {} + }, + { + "label": "numpy", + "kind": 6, + "isExtraImport": true, + "importPath": "numpy", + "description": "numpy", + "detail": "numpy", + "documentation": {} + }, + { + "label": "sys", + "kind": 6, + "isExtraImport": true, + "importPath": "sys", + "description": "sys", + "detail": "sys", + "documentation": {} + }, + { + "label": "typer", + "kind": 6, + "isExtraImport": true, + "importPath": "typer", + "description": "typer", + "detail": "typer", + "documentation": {} + }, + { + "label": "streamlit", + "kind": 6, + "isExtraImport": true, + "importPath": "streamlit", + "description": "streamlit", + "detail": "streamlit", + "documentation": {} + }, + { + "label": "webrtc_streamer", + "importPath": "streamlit_webrtc", + "description": "streamlit_webrtc", + "isExtraImport": true, + "detail": "streamlit_webrtc", + "documentation": {} + }, + { + "label": "WebRtcMode", + "importPath": "streamlit_webrtc", + "description": "streamlit_webrtc", + "isExtraImport": true, + "detail": "streamlit_webrtc", + "documentation": {} + }, + { + "label": "Console", + "importPath": "rich.console", + "description": "rich.console", + "isExtraImport": true, + "detail": "rich.console", + "documentation": {} + }, + { + "label": "Panel", + "importPath": "rich.panel", + "description": "rich.panel", + "isExtraImport": true, + "detail": "rich.panel", + "documentation": {} + }, + { + "label": "Progress", + "importPath": "rich.progress", + "description": "rich.progress", + "isExtraImport": true, + "detail": "rich.progress", + "documentation": {} + }, + { + "label": "random", + "kind": 6, + "isExtraImport": true, + "importPath": "random", + "description": "random", + "detail": "random", + "documentation": {} + }, + { + "label": "uvicorn", + "kind": 6, + "isExtraImport": true, + "importPath": "uvicorn", + "description": "uvicorn", + "detail": "uvicorn", + "documentation": {} + }, + { + "label": "re", + "kind": 6, + "isExtraImport": true, + "importPath": "re", + "description": "re", + "detail": "re", + "documentation": {} + }, + { + "label": "webbrowser", + "kind": 6, + "isExtraImport": true, + "importPath": "webbrowser", + "description": "webbrowser", + "detail": "webbrowser", + "documentation": {} + }, + { + "label": "threading", + "kind": 6, + "isExtraImport": true, + "importPath": "threading", + "description": "threading", + "detail": "threading", + "documentation": {} + }, + { + "label": "time", + "kind": 6, + "isExtraImport": true, + "importPath": "time", + "description": "time", + "detail": "time", + "documentation": {} + }, + { + "label": "router", + "importPath": "fastapi_source.host.ascii_art_routes", + "description": "fastapi_source.host.ascii_art_routes", + "isExtraImport": true, + "detail": "fastapi_source.host.ascii_art_routes", + "documentation": {} + }, + { + "label": "Route", + "importPath": "starlette.routing", + "description": "starlette.routing", + "isExtraImport": true, + "detail": "starlette.routing", + "documentation": {} + }, + { + "label": "matplotlib.pyplot", + "kind": 6, + "isExtraImport": true, + "importPath": "matplotlib.pyplot", + "description": "matplotlib.pyplot", + "detail": "matplotlib.pyplot", + "documentation": {} + }, + { + "label": "Delaunay", + "importPath": "scipy.spatial", + "description": "scipy.spatial", + "isExtraImport": true, + "detail": "scipy.spatial", + "documentation": {} + }, + { + "label": "importlib.util", + "kind": 6, + "isExtraImport": true, + "importPath": "importlib.util", + "description": "importlib.util", + "detail": "importlib.util", + "documentation": {} + }, + { + "label": "Menu", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "Scrollbar", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "StringVar", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "Text", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "Tk", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "Toplevel", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "filedialog", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "ttk", + "importPath": "tkinter", + "description": "tkinter", + "isExtraImport": true, + "detail": "tkinter", + "documentation": {} + }, + { + "label": "END", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "FALSE", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "NORMAL", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "E", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "N", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "S", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "W", + "importPath": "tkinter.constants", + "description": "tkinter.constants", + "isExtraImport": true, + "detail": "tkinter.constants", + "documentation": {} + }, + { + "label": "argparse", + "kind": 6, + "isExtraImport": true, + "importPath": "argparse", + "description": "argparse", + "detail": "argparse", + "documentation": {} + }, + { + "label": "os", + "kind": 6, + "isExtraImport": true, + "importPath": "os", + "description": "os", + "detail": "os", + "documentation": {} + }, + { + "label": "color", + "importPath": "skimage", + "description": "skimage", + "isExtraImport": true, + "detail": "skimage", + "documentation": {} + }, + { + "label": "filters", + "importPath": "skimage", + "description": "skimage", + "isExtraImport": true, + "detail": "skimage", + "documentation": {} + }, + { + "label": "scale_image", + "kind": 2, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "def scale_image(image, new_width=100):\n \"\"\"Resizes an image preserving the aspect ratio.\"\"\"\n (original_width, original_height) = image.size\n aspect_ratio = original_height / float(original_width)\n new_height = int(aspect_ratio * new_width)\n new_image = image.resize((new_width, new_height))\n return new_image\ndef convert_to_grayscale(image):\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image, range_width=25):", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "convert_to_grayscale", + "kind": 2, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "def convert_to_grayscale(image):\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image, range_width=25):\n \"\"\"Maps each pixel to an ascii char based on the range\n in which it lies.\n 0-255 is divided into 11 ranges of 25 pixels each.\n \"\"\"\n pixels_in_image = list(image.getdata())\n pixels_to_chars = [ASCII_CHARS[pixel_value // range_width] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "map_pixels_to_ascii_chars", + "kind": 2, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "def map_pixels_to_ascii_chars(image, range_width=25):\n \"\"\"Maps each pixel to an ascii char based on the range\n in which it lies.\n 0-255 is divided into 11 ranges of 25 pixels each.\n \"\"\"\n pixels_in_image = list(image.getdata())\n pixels_to_chars = [ASCII_CHARS[pixel_value // range_width] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image, new_width=100):\n image = scale_image(image)", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "convert_image_to_ascii", + "kind": 2, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "def convert_image_to_ascii(image, new_width=100):\n image = scale_image(image)\n image = convert_to_grayscale(image)\n pixels_to_chars = map_pixels_to_ascii_chars(image)\n len_pixels_to_chars = len(pixels_to_chars)\n image_ascii = [pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)]\n return \"\\n\".join(image_ascii)\ndef handle_image_conversion(image_filepath):\n image = None\n try:", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "handle_image_conversion", + "kind": 2, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "def handle_image_conversion(image_filepath):\n image = None\n try:\n image = Image.open(image_filepath)\n except Exception as e:\n print(\"Unable to open image file {image_filepath}.\".format(image_filepath=image_filepath))\n print(f\"Error: {e}\")\n return\n image_ascii = convert_image_to_ascii(image)\n print(image_ascii)", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "ASCII_CHARS", + "kind": 5, + "importPath": "example.makeArtPython3", + "description": "example.makeArtPython3", + "peekOfCode": "ASCII_CHARS = [\"#\", \"?\", \"%\", \".\", \"S\", \"+\", \".\", \"*\", \":\", \",\", \"@\"]\ndef scale_image(image, new_width=100):\n \"\"\"Resizes an image preserving the aspect ratio.\"\"\"\n (original_width, original_height) = image.size\n aspect_ratio = original_height / float(original_width)\n new_height = int(aspect_ratio * new_width)\n new_image = image.resize((new_width, new_height))\n return new_image\ndef convert_to_grayscale(image):\n return image.convert(\"L\")", + "detail": "example.makeArtPython3", + "documentation": {} + }, + { + "label": "scale_image", + "kind": 2, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "def scale_image(image, new_width=100):\n \"\"\"Resizes an image preserving the aspect ratio.\"\"\"\n (original_width, original_height) = image.size\n aspect_ratio = original_height / float(original_width)\n new_height = int(aspect_ratio * new_width)\n new_image = image.resize((new_width, new_height))\n return new_image\ndef convert_to_grayscale(image):\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image, range_width=25):", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "convert_to_grayscale", + "kind": 2, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "def convert_to_grayscale(image):\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image, range_width=25):\n \"\"\"Maps each pixel to an ascii char based on the range\n in which it lies.\n 0-255 is divided into 11 ranges of 25 pixels each.\n \"\"\"\n pixels_in_image = list(image.getdata())\n pixels_to_chars = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "map_pixels_to_ascii_chars", + "kind": 2, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "def map_pixels_to_ascii_chars(image, range_width=25):\n \"\"\"Maps each pixel to an ascii char based on the range\n in which it lies.\n 0-255 is divided into 11 ranges of 25 pixels each.\n \"\"\"\n pixels_in_image = list(image.getdata())\n pixels_to_chars = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image, new_width=100):\n image = scale_image(image)", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "convert_image_to_ascii", + "kind": 2, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "def convert_image_to_ascii(image, new_width=100):\n image = scale_image(image)\n image = convert_to_grayscale(image)\n pixels_to_chars = map_pixels_to_ascii_chars(image)\n len_pixels_to_chars = len(pixels_to_chars)\n image_ascii = [pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)]\n return \"\\n\".join(image_ascii)\ndef handle_image_conversion(image_filepath):\n image = None\n try:", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "handle_image_conversion", + "kind": 2, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "def handle_image_conversion(image_filepath):\n image = None\n try:\n image = Image.open(image_filepath)\n except Exception as e:\n print(f\"Unable to open image file {image_filepath}.\")\n print(e)\n return\n image_ascii = convert_image_to_ascii(image)\n print(image_ascii)", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "ASCII_CHARS", + "kind": 5, + "importPath": "example.make_art", + "description": "example.make_art", + "peekOfCode": "ASCII_CHARS = [\"#\", \"?\", \"%\", \".\", \"S\", \"+\", \".\", \"*\", \":\", \",\", \"@\"]\ndef scale_image(image, new_width=100):\n \"\"\"Resizes an image preserving the aspect ratio.\"\"\"\n (original_width, original_height) = image.size\n aspect_ratio = original_height / float(original_width)\n new_height = int(aspect_ratio * new_width)\n new_image = image.resize((new_width, new_height))\n return new_image\ndef convert_to_grayscale(image):\n return image.convert(\"L\")", + "detail": "example.make_art", + "documentation": {} + }, + { + "label": "get_mosaic_image", + "kind": 2, + "importPath": "fastapi_source.application.ascii.ascii_service", + "description": "fastapi_source.application.ascii.ascii_service", + "peekOfCode": "def get_mosaic_image(contents: bytes, block_size:int=10) -> Image:\n \"\"\"_summary_\n Args:\n contents (bytes): Input image bytes.\n block_size (int, optional): Sidelength of a mosaic block. Defaults to 10.\n Returns:\n Image: Output image.\n \"\"\" \n image = __get_image_from_bytes(contents)\n img = np.array(image)", + "detail": "fastapi_source.application.ascii.ascii_service", + "documentation": {} + }, + { + "label": "Settings", + "kind": 6, + "importPath": "fastapi_source.core.config", + "description": "fastapi_source.core.config", + "peekOfCode": "class Settings:\n PROJECT_NAME_EN_US: str = \"Ascii-Art Api\"\n VERSION: str = \"1.0.0\"\n #router setting\n ROUTER_NAME_Object_Detection, ROUTER_Description_Object_Detection = (\"AsciiArt\", \"Enjoy 😎😎😎\")\nsettings = Settings()", + "detail": "fastapi_source.core.config", + "documentation": {} + }, + { + "label": "settings", + "kind": 5, + "importPath": "fastapi_source.core.config", + "description": "fastapi_source.core.config", + "peekOfCode": "settings = Settings()", + "detail": "fastapi_source.core.config", + "documentation": {} + }, + { + "label": "router", + "kind": 5, + "importPath": "fastapi_source.host.ascii_art_routes", + "description": "fastapi_source.host.ascii_art_routes", + "peekOfCode": "router = APIRouter(prefix=f'/{settings.ROUTER_NAME_Object_Detection}', \n tags=[settings.ROUTER_NAME_Object_Detection])\n@router.put(\"/Mosaic\", summary = \"Make your image mosaic! 😁\", \n description = 'Upload your image file, and make it mosaic. 😃',\n response_class = StreamingResponse,\n responses = {200: {\"content\": {\"image/png\": {}}}})\nasync def detect(image_file: UploadFile = File(..., description=\"upload image file\"),\n block_size: int=Query(description=\"Sidelength of a mosaic block. Default value=10\", default=10)):\n contents = await image_file.read()\n result_image = get_mosaic_image(contents, block_size)", + "detail": "fastapi_source.host.ascii_art_routes", + "documentation": {} + }, + { + "label": "scale_image", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def scale_image(image: Image.Image, new_width: int = 100) -> Image.Image:\n (original_width, original_height) = image.size\n aspect_ratio: float = original_height / float(original_width)\n new_height: int = int(aspect_ratio * new_width)\n new_image: Image.Image = image.resize((new_width, new_height))\n return new_image\ndef convert_to_grayscale(image: Image.Image) -> Image.Image:\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "convert_to_grayscale", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def convert_to_grayscale(image: Image.Image) -> Image.Image:\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())\n pixels_to_chars: List[int] = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> Tuple[str, List[Tuple[int, int, int, int]]]:\n image = scale_image(image, new_width)\n grayscale_image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(grayscale_image)", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "map_pixels_to_ascii_chars", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())\n pixels_to_chars: List[int] = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> Tuple[str, List[Tuple[int, int, int, int]]]:\n image = scale_image(image, new_width)\n grayscale_image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(grayscale_image)\n len_pixels_to_chars: int = len(pixels_to_chars)\n image_ascii: List[str] = [pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)]", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "convert_image_to_ascii", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> Tuple[str, List[Tuple[int, int, int, int]]]:\n image = scale_image(image, new_width)\n grayscale_image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(grayscale_image)\n len_pixels_to_chars: int = len(pixels_to_chars)\n image_ascii: List[str] = [pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)]\n color_data: List[Tuple[int, int, int, int]] = list(image.convert(\"RGBA\").getdata())\n return \"\\n\".join(image_ascii), color_data\ndef get_char_for_position(x, y, lines, column_states, column_lengths):\n if x >= len(lines[y]):", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "get_char_for_position", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def get_char_for_position(x, y, lines, column_states, column_lengths):\n if x >= len(lines[y]):\n return \" \" # Pad shorter lines with spaces\n if column_states[x] == -1 or column_states[x] < y:\n return lines[y][x]\n if column_states[x] - column_lengths[x] <= y:\n if column_states[x] == y:\n return \" \"\n else:\n return chr(np.random.choice(list(range(33, 127)))) # Random ASCII characters excluding space", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "generate_new_frame", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def generate_new_frame(lines, column_states, column_lengths, height, width):\n new_frame = []\n for y in range(height):\n new_line = \"\".join(get_char_for_position(x, y, lines, column_states, column_lengths) for x in range(width))\n new_frame.append(new_line)\n return new_frame\ndef update_column_states(column_states, column_lengths, columns_covered, height, width):\n # Move the flow down faster\n column_states = [state + 2 if state != -1 else state for state in column_states]\n # Reset the flow if it reaches the bottom and mark columns as covered", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "update_column_states", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def update_column_states(column_states, column_lengths, columns_covered, height, width):\n # Move the flow down faster\n column_states = [state + 2 if state != -1 else state for state in column_states]\n # Reset the flow if it reaches the bottom and mark columns as covered\n for i in range(width):\n if column_states[i] >= height + column_lengths[i]:\n column_states[i] = -1\n columns_covered[i] = True # Mark this column as covered\n return column_states, columns_covered\ndef start_new_flows(column_states, column_lengths, columns_covered, height, width, t, skip_frames):", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "start_new_flows", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def start_new_flows(column_states, column_lengths, columns_covered, height, width, t, skip_frames):\n if t >= skip_frames:\n active_flows = sum(1 for state in column_states if state != -1)\n if active_flows < width:\n # Ensure all columns are eventually covered\n uncovered_columns = [i for i, covered in enumerate(columns_covered) if not covered]\n if uncovered_columns:\n i = np.random.choice(uncovered_columns)\n else:\n i = np.random.randint(0, width)", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "generate_matrix_effect", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def generate_matrix_effect(image_ascii: str) -> List[str]:\n lines = image_ascii.split(\"\\n\")\n height = len(lines)\n width = max(len(line) for line in lines) # Ensure all lines have the same width\n frames = []\n column_states = [-1] * width # -1 means no flow\n column_lengths = [0] * width\n columns_covered = [False] * width # Track which columns have been covered by the flow\n # Skip the first second (assuming 30 FPS, skip the first 30 frames)\n skip_frames = 30", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "create_video_from_frames", + "kind": 2, + "importPath": "ascii-art-matrix-effect-color", + "description": "ascii-art-matrix-effect-color", + "peekOfCode": "def create_video_from_frames(frames: List[str], color_data: List[Tuple[int, int, int, int]], width: int, output_path: str):\n height = len(frames[0].split(\"\\n\"))\n fourcc = cv2.VideoWriter_fourcc(*\"mp4v\")\n frame_rate = 30\n video = cv2.VideoWriter(output_path, fourcc, frame_rate, (width * 10, height * 10))\n # Track which characters have been part of the flow\n flow_passed = [[False] * width for _ in range(height)]\n for frame in frames:\n img = np.zeros((height * 10, width * 10, 3), dtype=np.uint8)\n for y, line in enumerate(frame.split(\"\\n\")):", + "detail": "ascii-art-matrix-effect-color", + "documentation": {} + }, + { + "label": "scale_image", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def scale_image(image: Image.Image, new_width: int = 100) -> Image.Image:\n (original_width, original_height) = image.size\n aspect_ratio: float = original_height / float(original_width)\n new_height: int = int(aspect_ratio * new_width)\n return image.resize((new_width, new_height))\ndef convert_to_grayscale(image: Image.Image) -> Image.Image:\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())\n pixels_to_chars: List[int] = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "convert_to_grayscale", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def convert_to_grayscale(image: Image.Image) -> Image.Image:\n return image.convert(\"L\")\ndef map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())\n pixels_to_chars: List[int] = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> str:\n image = scale_image(image, new_width)\n image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(image)", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "map_pixels_to_ascii_chars", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def map_pixels_to_ascii_chars(image: Image.Image, range_width: int = 25) -> str:\n pixels_in_image: List[int] = list(image.getdata())\n pixels_to_chars: List[int] = [ASCII_CHARS[int(pixel_value / range_width)] for pixel_value in pixels_in_image]\n return \"\".join(pixels_to_chars)\ndef convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> str:\n image = scale_image(image, new_width)\n image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(image)\n len_pixels_to_chars: int = len(pixels_to_chars)\n return \"\\n\".join([pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)])", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "convert_image_to_ascii", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def convert_image_to_ascii(image: Image.Image, new_width: int = 100) -> str:\n image = scale_image(image, new_width)\n image = convert_to_grayscale(image)\n pixels_to_chars: str = map_pixels_to_ascii_chars(image)\n len_pixels_to_chars: int = len(pixels_to_chars)\n return \"\\n\".join([pixels_to_chars[index : index + new_width] for index in range(0, len_pixels_to_chars, new_width)])\ndef generate_new_frame(image_ascii: str, column_states: List[int], height: int, width: int) -> str:\n \"\"\"Generates a new frame based on the current column states.\"\"\"\n new_frame = []\n lines = image_ascii.split(\"\\n\")", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "generate_new_frame", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def generate_new_frame(image_ascii: str, column_states: List[int], height: int, width: int) -> str:\n \"\"\"Generates a new frame based on the current column states.\"\"\"\n new_frame = []\n lines = image_ascii.split(\"\\n\")\n for y in range(height):\n new_line = \"\"\n for x in range(width):\n if x >= len(lines[y]):\n new_line += \" \" # Pad shorter lines with spaces\n elif column_states[x] == -1:", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "update_column_states", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def update_column_states(column_states: List[int], height: int, column_lengths: List[int]):\n \"\"\"Updates the column states and resets them if they reach the bottom.\"\"\"\n for i in range(len(column_states)):\n if column_states[i] >= height + column_lengths[i]:\n column_states[i] = -1\n return column_states\ndef generate_matrix_effect(image_ascii: str, frame_count: int) -> List[str]:\n \"\"\"Generates frames for the matrix effect.\"\"\"\n lines = image_ascii.split(\"\\n\")\n height = len(lines)", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "generate_matrix_effect", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def generate_matrix_effect(image_ascii: str, frame_count: int) -> List[str]:\n \"\"\"Generates frames for the matrix effect.\"\"\"\n lines = image_ascii.split(\"\\n\")\n height = len(lines)\n width = max(len(line) for line in lines)\n frames = []\n flow_count = width\n column_states = [-1] * width # -1 means no flow\n column_lengths = [0] * width\n # Skip the first second (assuming 30 FPS, skip the first 30 frames)", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "create_video_from_frames", + "kind": 2, + "importPath": "ascii-art-matrix-effect", + "description": "ascii-art-matrix-effect", + "peekOfCode": "def create_video_from_frames(frames: List[str], output_path: str):\n \"\"\"Creates a video from ASCII frames.\"\"\"\n height = len(frames[0].split(\"\\n\"))\n width = len(frames[0].split(\"\\n\")[0])\n fourcc = cv2.VideoWriter_fourcc(*\"mp4v\")\n frame_rate = 30\n video = cv2.VideoWriter(output_path, fourcc, frame_rate, (width * 10, height * 10))\n for frame in frames:\n img = np.zeros((height * 10, width * 10, 3), dtype=np.uint8)\n for y, line in enumerate(frame.split(\"\\n\")):", + "detail": "ascii-art-matrix-effect", + "documentation": {} + }, + { + "label": "resize_image", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def resize_image(image, new_width=100):\n width, height = image.size\n aspect_ratio = height / width\n new_height = int(aspect_ratio * new_width * 0.55)\n return image.resize((new_width, new_height))\ndef apply_image_filters(image, brightness, contrast, blur, sharpen):\n if brightness != 1.0:\n image = ImageEnhance.Brightness(image).enhance(brightness)\n if contrast != 1.0:\n image = ImageEnhance.Contrast(image).enhance(contrast)", + "detail": "community-version", + "documentation": {} + }, + { + "label": "apply_image_filters", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def apply_image_filters(image, brightness, contrast, blur, sharpen):\n if brightness != 1.0:\n image = ImageEnhance.Brightness(image).enhance(brightness)\n if contrast != 1.0:\n image = ImageEnhance.Contrast(image).enhance(contrast)\n if blur:\n image = image.filter(ImageFilter.BLUR)\n if sharpen:\n image = image.filter(ImageFilter.SHARPEN)\n return image", + "detail": "community-version", + "documentation": {} + }, + { + "label": "text_to_image", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def text_to_image(text, canvas_width, canvas_height):\n image = Image.new('RGB', (canvas_width, canvas_height), color='white')\n draw = ImageDraw.Draw(image)\n font = ImageFont.load_default()\n text_width, text_height = draw.textsize(text, font=font)\n position = ((canvas_width - text_width) / 2,\n (canvas_height - text_height) / 2)\n draw.text(position, text, fill='black', font=font)\n return image\n# Function to flip image", + "detail": "community-version", + "documentation": {} + }, + { + "label": "flip_image", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def flip_image(image: Image.Image, flip_horizontal: bool, flip_vertical: bool) -> Image.Image:\n if flip_horizontal:\n image = ImageOps.mirror(image) # Flip horizontally\n if flip_vertical:\n image = ImageOps.flip(image) # Flip vertically\n return image\ndef create_ascii_art(image, pattern, colorize=False, theme='grayscale'):\n ascii_chars = ASCII_PATTERNS[pattern]\n ascii_art = []\n pixels = np.array(image)", + "detail": "community-version", + "documentation": {} + }, + { + "label": "create_ascii_art", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def create_ascii_art(image, pattern, colorize=False, theme='grayscale'):\n ascii_chars = ASCII_PATTERNS[pattern]\n ascii_art = []\n pixels = np.array(image)\n for y in range(image.height):\n line = []\n for x in range(image.width):\n pixel = pixels[y, x]\n char_index = int(np.mean(pixel) / 255 * (len(ascii_chars) - 1))\n char = ascii_chars[char_index]", + "detail": "community-version", + "documentation": {} + }, + { + "label": "map_pixels_to_ascii", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def map_pixels_to_ascii(image: Image.Image, pattern: list) -> str:\n grayscale_image = image.convert('L')\n pixels = np.array(grayscale_image)\n ascii_chars = np.vectorize(lambda pixel: pattern[min(pixel // (256 // len(pattern)), len(pattern) - 1)])(pixels)\n ascii_image = \"\\n\".join([\"\".join(row) for row in ascii_chars])\n return ascii_image\n# Function to create colorized ASCII art in HTML format\ndef create_colorized_ascii_html(image: Image.Image, pattern: list, theme: str) -> str:\n image = resize_image(image, 80, 'basic')\n pixels = np.array(image)", + "detail": "community-version", + "documentation": {} + }, + { + "label": "create_colorized_ascii_html", + "kind": 2, + "importPath": "community-version", + "description": "community-version", + "peekOfCode": "def create_colorized_ascii_html(image: Image.Image, pattern: list, theme: str) -> str:\n image = resize_image(image, 80, 'basic')\n pixels = np.array(image)\n ascii_image_html = \"\"\"\n