Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _read_bytes function in images.py support for URL #548

Closed
wants to merge 1 commit into from

Commits on Apr 26, 2024

  1. Update images.py

    Add support for fetching images from URLs in _read_bytes_image
    
    Previously, the function only supported reading image files from local paths. This commit extends its functionality to also fetch images from URLs if the path starts with 'http://' or 'https://'. The function now uses the 'requests' library to download the image content when a URL is provided.
    
    If the URL fetch is successful, the image content is returned as bytes. If the status code is not 200, a ValueError is raised with a message indicating the failure.
    
    The existing file reading functionality remains unchanged for non-URL paths, ensuring backward compatibility.
    
    Changes:
    - Modified _read_bytes_image to check if the path is a URL
    - Added conditional logic to handle URL paths using requests.get
    - Included error handling for failed URL fetch attempts
    stoensin committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    ace4c5b View commit details
    Browse the repository at this point in the history