diff --git a/hermes_cli/clipboard.py b/hermes_cli/clipboard.py index a782c876b26..a6b6da7c06a 100644 --- a/hermes_cli/clipboard.py +++ b/hermes_cli/clipboard.py @@ -440,7 +440,8 @@ def _convert_to_png(path: Path) -> bool: def _is_png_file(path: Path) -> bool: """Return True when *path* starts with the PNG file signature.""" try: - return path.read_bytes().startswith(_PNG_SIGNATURE) + with path.open("rb") as f: + return f.read(len(_PNG_SIGNATURE)) == _PNG_SIGNATURE except OSError: return False