Created
September 8, 2024 09:55
-
-
Save shinshin86/1df07e1a6374906eda6e1fcee0d0d2e1 to your computer and use it in GitHub Desktop.
Revisions
-
shinshin86 created this gist
Sep 8, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ from PIL import Image import sys def get_png_info(file_path): try: with Image.open(file_path) as img: if img.format != 'PNG': return "This is not a PNG image." info = img.info result = "PNG Information:\n" for key, value in info.items(): result += f"{key}: {value}\n" return result except Exception as e: return f"An error occurred: {str(e)}" if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python checkpnginfo.py <path_to_png_file>") else: file_path = sys.argv[1] print(get_png_info(file_path))