Skip to content

Image issues #92

@zhiltsov-max

Description

@zhiltsov-max
  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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions