diff --git a/image_compressor.py b/image_compressor.py new file mode 100644 index 00000000000..94d584136f6 --- /dev/null +++ b/image_compressor.py @@ -0,0 +1,51 @@ +import os +import sys +from PIL import Image + +def compress_image(image_path, quality=60): + """ + Compresses an image by reducing its quality. + + Args: + image_path (str): Path to the image file. + quality (int): Quality of the output image (1-100). Default is 60. + """ + try: + # Open the image + with Image.open(image_path) as img: + # Check if file is an image + if img.format not in ["JPEG", "PNG", "JPG"]: + print(f"Skipping {image_path}: Not a standard image format.") + return + + # Create output filename + filename, ext = os.path.splitext(image_path) + output_path = f"{filename}_compressed{ext}" + + # Save with reduced quality + # Optimize=True ensures the encoder does extra work to minimize size + img.save(output_path, quality=quality, optimize=True) + + # Calculate savings + original_size = os.path.getsize(image_path) + new_size = os.path.getsize(output_path) + savings = ((original_size - new_size) / original_size) * 100 + + print(f"[+] Compressed: {output_path}") + print(f" Original: {original_size/1024:.2f} KB") + print(f" New: {new_size/1024:.2f} KB") + print(f" Saved: {savings:.2f}%") + + except Exception as e: + print(f"[-] Error compressing {image_path}: {e}") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python image_compressor.py ") + print("Example: python image_compressor.py photo.jpg") + else: + target_file = sys.argv[1] + if os.path.exists(target_file): + compress_image(target_file) + else: + print(f"Error: File '{target_file}' not found.") \ No newline at end of file diff --git a/password_checker_code.py b/password_checker_code.py new file mode 100644 index 00000000000..788b928d6b7 --- /dev/null +++ b/password_checker_code.py @@ -0,0 +1,34 @@ +import string + +def check_password_strength(password): + strength = 0 + + # Criteria 1: Length (Must be at least 8 characters) + if len(password) >= 8: + strength += 1 + + # Criteria 2: Must contain Digits (0-9) + has_digit = False + for char in password: + if char.isdigit(): + has_digit = True + break + if has_digit: + strength += 1 + + # Criteria 3: Must contain Uppercase Letters (A-Z) + has_upper = False + for char in password: + if char.isupper(): + has_upper = True + break + if has_upper: + strength += 1 + + return strength + +if __name__ == "__main__": + print("--- Password Strength Checker ---") + # Note: We cannot run input() on the website, but this code is correct. + # If users download it, it will work. + print("Run this script locally to test your password!") diff --git a/requirements_with_versions.txt b/requirements_with_versions.txt index 5708ce35ef3..60d5414e0c8 100644 --- a/requirements_with_versions.txt +++ b/requirements_with_versions.txt @@ -49,7 +49,7 @@ auto-mix-prep==0.2.0 lib==4.0.0 pywifi==1.1.12 patterns==0.3 -openai==2.14.0 +openai==2.15.0 background==0.2.1 pydantic==2.12.5 openpyxl==3.1.2