abstract-images


Nameabstract-images JSON
Version 0.0.0.5 PyPI version JSON
download
home_pagehttps://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images
SummaryThis module, part of the `abstract_essentials` package, provides a collection of utility functions for working with images and PDFs, including loading and saving images, extracting text from images, capturing screenshots, processing PDFs, and more.
upload_time2023-08-30 22:34:16
maintainer
docs_urlNone
authorputkoff
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## `abstract_images` Module - Image and PDF Utilities

### Part of the `abstract_essentials` Package

**GitHub Repository**: [abstract_essentials](https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images)  
**Contact Email**: [partners@abstractendeavors.com](mailto:partners@abstractendeavors.com)  
**Date**: 08/27/2023  
**Version**: 0.0.0.1  

This module, part of the `abstract_essentials` package, provides a collection of utility functions for working with images and PDFs, including loading and saving images, extracting text from images, capturing screenshots, processing PDFs, and more.

### Image Utilities - `image_utils.py`

The `image_utils.py` module contains functions for image-related operations.

#### Paths to Image Data:

- **get_dimensions(image_path: str)**: Return dimensions (height, width) of the image.
- **img_to_str(image_path: str)**: Convert image to text using pytesseract.
- **get_pix(image_path: str)**: Return pixel data of the image.
- **image_to_bytes(image_path: str, format: str = "PNG")**: Convert an image to bytes.
- **get_pixel_data(image_path: str)**: Get pixel data from the image and save the resultant image.
- **open_image(image_path: str)**: Open and return the image using PIL.
- **read_image(image_path: str)**: Read image using OpenCV and return it as a numpy array.

#### Paths to Save:

- **save_url_img(url: str , image_path:str, format: str = "PNG")**: Download an image from URL and save it.
- **screenshot(image_path: str = "screenshot.png")**: Take a screenshot and save it.
- **save_image(image:Union[Image.Image, ndarray], image_path:str,format:str="PNG")**: Save an image to the specified path.

#### Data to Image:

- **get_image_bytes(image_data: bytes)**: Convert image data in bytes format to a BytesIO stream.
- **pix_to_img(pixel_data: List[List[Tuple[int, int, int]]], image_path: str = "image.png")**: Convert pixel data to an image and save it.
- **show_image(image: Union[Image.Image, ndarray])**: Display an image.

### PDF Utilities - `pdf_utils.py`

The `pdf_utils.py` module provides functions for PDF processing.

#### Function Descriptions:

- `if_none_return(obj, obj_2)`: Return primary object if secondary object is `None`.
- `write_pdf()`: Initialize and return a new PDF writer object.
- `read_pdf(file)`: Read a PDF from a given path and return a PDF reader object.
- `is_pdf_path(file)`: Check if a file path corresponds to a valid PDF file.
- `get_pdf_obj(pdf_obj)`: Process a PDF object or file path and return its content.
- `split_pdf(input_path, output_folder, file_name)`: Split a PDF file into separate pages.
- `pdf_to_img_list(pdf_list, output_folder, file_name, paginate, extension)`: Convert PDF files into images.
- `img_to_txt_list(img_list, output_folder, file_name, paginate, extension)`: Convert images to text using OCR.
- `open_pdf_file(pdf_file_path)`: Open a PDF file using the default system application.
- `image_to_text(image_path)`: Convert an image to text using Tesseract OCR.
- `get_pdfs_in_directory(directory)`: Get a list of PDF filenames in a directory.
- `get_all_pdf_in_directory(file_directory)`: Get full paths of all PDFs in a directory.
- `collate_pdfs(pdf_list, output_pdf_path)`: Merge a list of PDFs into one.

### Example Usage:

To showcase the `pdf_utils` module, here's an example combining several utility functions:

```python
from abstract_images.pdf_utils import (
    get_file_name, get_directory, mkdirs, split_pdf, 
    pdf_to_img_list, img_to_txt_list
)

pdf_path = "path_to_pdf"
file_name = get_file_name(pdf_path)
directory = get_directory(pdf_path)
pdf_folder = mkdirs(os.path.join(directory, file_name))

pdf_split_folder = mkdirs(os.path.join(pdf_folder, "split"))
pdf_list = split_pdf(input_path=pdf_path, output_folder=pdf_split_folder, file_name=file_name)

pdf_Image_folder = mkdirs(os.path.join(pdf_folder, "images"))
img_list = pdf_to_img_list(pdf_list=pdf_list, output_folder=pdf_Image_folder, paginate=False, extension="png")

pdf_Text_folder = mkdirs(os.path.join(pdf_folder, "text"))
text_list = img_to_txt_list(img_list=img_list, output_folder=pdf_Text_folder, paginate=False, extension="txt")
```

### Note:

For queries, bug reports, or feature requests, please raise an issue on the [GitHub repository](https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images) or contact us through the provided email: [partners@abstractendeavors.com](mailto:partners@abstractendeavors.com). Ensure that you have the required dependencies installed, and for OCR operations, ensure Tesseract is properly set up and its path is correctly specified.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images",
    "name": "abstract-images",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "putkoff",
    "author_email": "partners@abstractendeavors.com",
    "download_url": "",
    "platform": null,
    "description": "## `abstract_images` Module - Image and PDF Utilities\n\n### Part of the `abstract_essentials` Package\n\n**GitHub Repository**: [abstract_essentials](https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images)  \n**Contact Email**: [partners@abstractendeavors.com](mailto:partners@abstractendeavors.com)  \n**Date**: 08/27/2023  \n**Version**: 0.0.0.1  \n\nThis module, part of the `abstract_essentials` package, provides a collection of utility functions for working with images and PDFs, including loading and saving images, extracting text from images, capturing screenshots, processing PDFs, and more.\n\n### Image Utilities - `image_utils.py`\n\nThe `image_utils.py` module contains functions for image-related operations.\n\n#### Paths to Image Data:\n\n- **get_dimensions(image_path: str)**: Return dimensions (height, width) of the image.\n- **img_to_str(image_path: str)**: Convert image to text using pytesseract.\n- **get_pix(image_path: str)**: Return pixel data of the image.\n- **image_to_bytes(image_path: str, format: str = \"PNG\")**: Convert an image to bytes.\n- **get_pixel_data(image_path: str)**: Get pixel data from the image and save the resultant image.\n- **open_image(image_path: str)**: Open and return the image using PIL.\n- **read_image(image_path: str)**: Read image using OpenCV and return it as a numpy array.\n\n#### Paths to Save:\n\n- **save_url_img(url: str , image_path:str, format: str = \"PNG\")**: Download an image from URL and save it.\n- **screenshot(image_path: str = \"screenshot.png\")**: Take a screenshot and save it.\n- **save_image(image:Union[Image.Image, ndarray], image_path:str,format:str=\"PNG\")**: Save an image to the specified path.\n\n#### Data to Image:\n\n- **get_image_bytes(image_data: bytes)**: Convert image data in bytes format to a BytesIO stream.\n- **pix_to_img(pixel_data: List[List[Tuple[int, int, int]]], image_path: str = \"image.png\")**: Convert pixel data to an image and save it.\n- **show_image(image: Union[Image.Image, ndarray])**: Display an image.\n\n### PDF Utilities - `pdf_utils.py`\n\nThe `pdf_utils.py` module provides functions for PDF processing.\n\n#### Function Descriptions:\n\n- `if_none_return(obj, obj_2)`: Return primary object if secondary object is `None`.\n- `write_pdf()`: Initialize and return a new PDF writer object.\n- `read_pdf(file)`: Read a PDF from a given path and return a PDF reader object.\n- `is_pdf_path(file)`: Check if a file path corresponds to a valid PDF file.\n- `get_pdf_obj(pdf_obj)`: Process a PDF object or file path and return its content.\n- `split_pdf(input_path, output_folder, file_name)`: Split a PDF file into separate pages.\n- `pdf_to_img_list(pdf_list, output_folder, file_name, paginate, extension)`: Convert PDF files into images.\n- `img_to_txt_list(img_list, output_folder, file_name, paginate, extension)`: Convert images to text using OCR.\n- `open_pdf_file(pdf_file_path)`: Open a PDF file using the default system application.\n- `image_to_text(image_path)`: Convert an image to text using Tesseract OCR.\n- `get_pdfs_in_directory(directory)`: Get a list of PDF filenames in a directory.\n- `get_all_pdf_in_directory(file_directory)`: Get full paths of all PDFs in a directory.\n- `collate_pdfs(pdf_list, output_pdf_path)`: Merge a list of PDFs into one.\n\n### Example Usage:\n\nTo showcase the `pdf_utils` module, here's an example combining several utility functions:\n\n```python\nfrom abstract_images.pdf_utils import (\n    get_file_name, get_directory, mkdirs, split_pdf, \n    pdf_to_img_list, img_to_txt_list\n)\n\npdf_path = \"path_to_pdf\"\nfile_name = get_file_name(pdf_path)\ndirectory = get_directory(pdf_path)\npdf_folder = mkdirs(os.path.join(directory, file_name))\n\npdf_split_folder = mkdirs(os.path.join(pdf_folder, \"split\"))\npdf_list = split_pdf(input_path=pdf_path, output_folder=pdf_split_folder, file_name=file_name)\n\npdf_Image_folder = mkdirs(os.path.join(pdf_folder, \"images\"))\nimg_list = pdf_to_img_list(pdf_list=pdf_list, output_folder=pdf_Image_folder, paginate=False, extension=\"png\")\n\npdf_Text_folder = mkdirs(os.path.join(pdf_folder, \"text\"))\ntext_list = img_to_txt_list(img_list=img_list, output_folder=pdf_Text_folder, paginate=False, extension=\"txt\")\n```\n\n### Note:\n\nFor queries, bug reports, or feature requests, please raise an issue on the [GitHub repository](https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images) or contact us through the provided email: [partners@abstractendeavors.com](mailto:partners@abstractendeavors.com). Ensure that you have the required dependencies installed, and for OCR operations, ensure Tesseract is properly set up and its path is correctly specified.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This module, part of the `abstract_essentials` package, provides a collection of utility functions for working with images and PDFs, including loading and saving images, extracting text from images, capturing screenshots, processing PDFs, and more.",
    "version": "0.0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_images"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a00c097b7ec51ba2e3e80d7e74a85a2a5130a04cd41d4f6f3626b186a5850222",
                "md5": "334071ae41a42fbe609897976fb42520",
                "sha256": "60b831060332bca0a74038803db0b16898d2db1b0556938cd0a6c29ae1a54c9f"
            },
            "downloads": -1,
            "filename": "abstract_images-0.0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "334071ae41a42fbe609897976fb42520",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 16660,
            "upload_time": "2023-08-30T22:34:16",
            "upload_time_iso_8601": "2023-08-30T22:34:16.447532Z",
            "url": "https://files.pythonhosted.org/packages/a0/0c/097b7ec51ba2e3e80d7e74a85a2a5130a04cd41d4f6f3626b186a5850222/abstract_images-0.0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-30 22:34:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AbstractEndeavors",
    "github_project": "abstract_essentials",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "abstract-images"
}
        
Elapsed time: 0.16173s