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

Image issues #92

Open
zhiltsov-max opened this issue Mar 6, 2025 · 0 comments
Open

Image issues #92

zhiltsov-max opened this issue Mar 6, 2025 · 0 comments
Assignees

Comments

@zhiltsov-max
Copy link
Collaborator

zhiltsov-max commented Mar 6, 2025

  1. save_image() uses the "png" extension by default for non-string fp param. It should be an error instead, because otherwise it can lead to unexpected image conversions.

Potential fix:

    if isinstance(dst, IOBase):
        if not ext:
            raise ValueError("Image extension must be specified")
    else:
        # NOTE: Check destination path for existence
        # OpenCV silently fails if target directory does not exist
        dst_dir = osp.dirname(dst)
        if dst_dir:
            if create_dir:
                os.makedirs(dst_dir, exist_ok=True)
            elif not osp.isdir(dst_dir):
                raise FileNotFoundError("Directory does not exist: '%s'" % dst_dir)

        # file extension and actual encoding can differ
        ext = ext if ext else osp.splitext(dst)[1]
  1. save_image() doesn't support crypters for no reason when Pillow backend is used.
  2. Image should not have a default extension of "png". It can be a default extension for VideoFrame, which currently doesn't have a default format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants