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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Thumbs.db
# Temporary files
*.tmp
*.temp
AGENTS.md

# FFmpeg temp files
ffmpeg2pass-*.log
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "compresscli"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
authors = ["AmitxD"]
description = "A powerful CLI tool for video and image compression"
Expand Down
8 changes: 4 additions & 4 deletions examples/TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ compresscli video sample_video.mp4 --no-audio
compresscli video sample_video.mp4 --bitrate 1M --two-pass

# Complex combination
compresscli video sample_video.mp4 \\
--preset slow \\
--crf 20 \\
--resolution 720p \\
compresscli video sample_video.mp4 \
--preset slow \
--crf 20 \
--resolution 720p \
--audio-bitrate 128k
```

Expand Down
8 changes: 4 additions & 4 deletions examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ image_presets:
default_settings:
# Default output directory (null = same as input)
output_dir: null

# Overwrite existing files by default
overwrite: false

# Number of parallel jobs for batch processing
parallel_jobs: 4

# Preserve original file metadata
preserve_metadata: true

# Create backup of original files
backup_originals: false
60 changes: 30 additions & 30 deletions examples/create_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,125 +12,125 @@ def create_sample_images():
"""Create sample images for testing"""
samples_dir = "examples/samples"
os.makedirs(samples_dir, exist_ok=True)

# Create a large sample image (4K)
img_4k = Image.new('RGB', (3840, 2160), color='skyblue')
draw = ImageDraw.Draw(img_4k)

# Add some text and shapes
try:
# Try to use a default font, fallback to basic if not available
font = ImageFont.load_default()
except:
font = None

# Draw some shapes and text
draw.rectangle([100, 100, 1000, 600], fill='red', outline='black', width=5)
draw.ellipse([2000, 500, 3500, 1500], fill='green', outline='blue', width=10)
draw.text((200, 200), "Sample 4K Image", fill='white', font=font)
draw.text((200, 300), "For CompressCLI Testing", fill='white', font=font)

img_4k.save(f"{samples_dir}/sample_4k.png")
print("Created sample_4k.png (3840x2160)")

# Create a medium sample image (1080p)
img_1080p = Image.new('RGB', (1920, 1080), color='lightgreen')
draw = ImageDraw.Draw(img_1080p)

# Add gradient effect
for i in range(1920):
color_val = int(255 * (i / 1920))
draw.line([(i, 0), (i, 1080)], fill=(color_val, 100, 255 - color_val))

draw.text((100, 100), "Sample 1080p Image", fill='white', font=font)
draw.text((100, 150), "Gradient Background", fill='white', font=font)

img_1080p.save(f"{samples_dir}/sample_1080p.jpg", quality=95)
print("Created sample_1080p.jpg (1920x1080)")

# Create a small sample image (720p)
img_720p = Image.new('RGB', (1280, 720), color='orange')
draw = ImageDraw.Draw(img_720p)

# Create a pattern
for x in range(0, 1280, 50):
for y in range(0, 720, 50):
color = (x % 255, y % 255, (x + y) % 255)
draw.rectangle([x, y, x+40, y+40], fill=color)

draw.text((50, 50), "Sample 720p Image", fill='white', font=font)
draw.text((50, 100), "Pattern Background", fill='white', font=font)

img_720p.save(f"{samples_dir}/sample_720p.webp", quality=90)
print("Created sample_720p.webp (1280x720)")

# Create a photo-like sample
img_photo = Image.new('RGB', (2048, 1536), color='lightblue')
draw = ImageDraw.Draw(img_photo)

# Simulate a landscape
# Sky
for y in range(500):
color_val = int(135 + (y / 500) * 120)
draw.line([(0, y), (2048, y)], fill=(color_val, color_val + 20, 255))

# Ground
for y in range(500, 1536):
color_val = int(34 + ((y - 500) / 1036) * 100)
draw.line([(0, y), (2048, y)], fill=(color_val, color_val + 50, color_val))

# Add some "mountains"
points = [(0, 500), (300, 200), (600, 350), (900, 150), (1200, 300), (1500, 100), (1800, 250), (2048, 180), (2048, 500)]
draw.polygon(points, fill='gray')

draw.text((100, 1400), "Sample Photo-like Image", fill='white', font=font)
draw.text((100, 1450), "Landscape Simulation", fill='white', font=font)

img_photo.save(f"{samples_dir}/sample_photo.jpg", quality=85)
print("Created sample_photo.jpg (2048x1536)")

def create_sample_video():
"""Create a sample video for testing"""
try:
import cv2

samples_dir = "examples/samples"

# Video properties
width, height = 1280, 720
fps = 30
duration = 10 # seconds
total_frames = fps * duration

# Create video writer
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(f'{samples_dir}/sample_video.mp4', fourcc, fps, (width, height))

for frame_num in range(total_frames):
# Create a frame with changing colors
frame = np.zeros((height, width, 3), dtype=np.uint8)

# Create a moving gradient
for y in range(height):
for x in range(width):
r = int(128 + 127 * np.sin(2 * np.pi * frame_num / 60 + x / 100))
g = int(128 + 127 * np.sin(2 * np.pi * frame_num / 60 + y / 100))
b = int(128 + 127 * np.sin(2 * np.pi * frame_num / 60 + (x + y) / 200))
frame[y, x] = [b, g, r] # OpenCV uses BGR

# Add frame counter text
cv2.putText(frame, f'Frame {frame_num + 1}/{total_frames}',
cv2.putText(frame, f'Frame {frame_num + 1}/{total_frames}',
(50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
cv2.putText(frame, f'Time: {frame_num/fps:.1f}s',
cv2.putText(frame, f'Time: {frame_num/fps:.1f}s',
(50, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
cv2.putText(frame, 'Sample Video for CompressCLI',
cv2.putText(frame, 'Sample Video for CompressCLI',
(50, height - 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

out.write(frame)

out.release()
print(f"Created sample_video.mp4 ({width}x{height}, {duration}s)")

except ImportError:
print("OpenCV not available, skipping video creation")
print("To create sample video, install: pip install opencv-python numpy")
Expand Down
34 changes: 15 additions & 19 deletions examples/create_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "Creating sample files for CompressCLI testing..."
# Check if ImageMagick is available
if command -v convert &> /dev/null; then
echo "Creating sample images with ImageMagick..."

# Create a 4K sample image
convert -size 3840x2160 gradient:blue-red \
-pointsize 72 -fill white -gravity center \
Expand All @@ -20,7 +20,7 @@ if command -v convert &> /dev/null; then
-annotate +0+0 "3840x2160 Resolution" \
"$SAMPLES_DIR/sample_4k.png"
echo "Created sample_4k.png (3840x2160)"

# Create a 1080p sample image
convert -size 1920x1080 gradient:green-yellow \
-pointsize 48 -fill black -gravity center \
Expand All @@ -29,7 +29,7 @@ if command -v convert &> /dev/null; then
-annotate +0+0 "1920x1080 Resolution" \
"$SAMPLES_DIR/sample_1080p.jpg"
echo "Created sample_1080p.jpg (1920x1080)"

# Create a 720p sample image
convert -size 1280x720 plasma:fractal \
-pointsize 36 -fill white -gravity center \
Expand All @@ -38,7 +38,7 @@ if command -v convert &> /dev/null; then
-annotate +0+50 "1280x720 Resolution" \
"$SAMPLES_DIR/sample_720p.webp"
echo "Created sample_720p.webp (1280x720)"

# Create a photo-like sample
convert -size 2048x1536 gradient:skyblue-lightgreen \
-pointsize 42 -fill darkblue -gravity center \
Expand All @@ -48,13 +48,13 @@ if command -v convert &> /dev/null; then
-annotate +0+50 "Perfect for testing compression" \
"$SAMPLES_DIR/sample_photo.jpg"
echo "Created sample_photo.jpg (2048x1536)"

else
echo "ImageMagick not found. Creating simple sample images with basic tools..."

# Create simple colored images using printf and convert to images
# This is a fallback method that works on most systems

# Create a simple test pattern file
cat > "$SAMPLES_DIR/sample_text.txt" << EOF
This is a sample text file that can be converted to an image.
Expand All @@ -72,38 +72,34 @@ Use this for testing:

Sample created for CompressCLI project.
EOF

echo "Created sample text file (can be used for testing)"
fi

# Check if FFmpeg is available for video creation
if command -v ffmpeg &> /dev/null; then
echo "Creating sample video with FFmpeg..."

# Create a 10-second test video with color bars and timer
ffmpeg -f lavfi -i testsrc2=duration=10:size=1280x720:rate=30 \
if ffmpeg -f lavfi -i testsrc2=duration=10:size=1280x720:rate=30 \
-f lavfi -i sine=frequency=1000:duration=10 \
-c:v libx264 -preset fast -crf 23 \
-c:a aac -b:a 128k \
-y "$SAMPLES_DIR/sample_video.mp4" 2>/dev/null

if [ $? -eq 0 ]; then
-y "$SAMPLES_DIR/sample_video.mp4" 2>/dev/null; then
echo "Created sample_video.mp4 (1280x720, 10s)"
else
echo "Failed to create sample video"
fi

# Create a shorter sample for quick testing
ffmpeg -f lavfi -i testsrc=duration=5:size=854x480:rate=25 \
if ffmpeg -f lavfi -i testsrc=duration=5:size=854x480:rate=25 \
-f lavfi -i sine=frequency=800:duration=5 \
-c:v libx264 -preset ultrafast -crf 28 \
-c:a aac -b:a 96k \
-y "$SAMPLES_DIR/sample_short.mp4" 2>/dev/null

if [ $? -eq 0 ]; then
-y "$SAMPLES_DIR/sample_short.mp4" 2>/dev/null; then
echo "Created sample_short.mp4 (854x480, 5s)"
fi

else
echo "FFmpeg not found. Skipping video creation."
echo "Install FFmpeg to create sample videos."
Expand Down
Loading