Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions image_compressor.py
Original file line number Diff line number Diff line change
@@ -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 <image_file>")
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.")
34 changes: 34 additions & 0 deletions password_checker_code.py
Original file line number Diff line number Diff line change
@@ -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!")
2 changes: 1 addition & 1 deletion requirements_with_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading