Compress each of these images to under twenty KB.
mkdir -p /home/daytona/workspace/compressed-images && cd /home/daytona/workspace/compressed-images && curl -s -o img1.jpeg "https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-16-1-1778594180060-kgljcs.jpeg" && curl -s -o img2.jpeg "https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-16-1778594180056-3ad6kl.jpeg" && curl -s -o img3.jpeg "https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-15-1778594180085-94a7ng.jpeg" && curl -s -o img4.jpeg "https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-15-1-1778594180086-zrsa87.jpeg" && ls -lh *.jpeg
cd /home/daytona/workspace/compressed-images # Compress each image to under 20KB using Python Pillow with progressive quality reduction python3 << 'EOF' from PIL import Image import os files = { "img1.jpeg": "WhatsApp Image 2026-05-12 at 19.19.16 (1).jpeg", "img2.jpeg": "WhatsApp Image 2026-05-12 at 19.19.16.jpeg", "img3.jpeg": "WhatsApp Image 2026-05-12 at 19.19.15.jpeg", "img4.jpeg": "WhatsApp Image 2026-05-12 at 19.19.15 (1).jpeg", } TARGET = 20 * 1024 # 20 KB for src, dst in files.items(): img = Image.open(src) # Try reducing quality first for quality in range(85, 0, -5): out_path = f"compressed_{dst}" img.save(out_path, "JPEG", quality=quality, optimize=True) size = os.path.getsize(out_path) if size < TARGET: print(f"{dst}: quality={quality}, size={size/1024:.1f} KB ✓") break else: # Need to also resize w, h = img.size for scale in [0.5, 0.4, 0.3, 0.25, 0.2, 0.15, 0.1]: resized = img.resize((int(w*scale), int(h*scale)), Image.LANCZOS) for quality in range(85, 5, -5): out_path = f"compressed_{dst}" resized.save(out_path, "JPEG", quality=quality, optimize=True) size = os.path.getsize(out_path) if size < TARGET: print(f"{dst}: scale={scale}, quality={quality}, size={size/1024:.1f} KB ✓") break else: continue break else: print(f"{dst}: FAILED to compress below 20KB") EOF
| File | Compressed Size |
|---|---|
| [WhatsApp Image 2026-05-12 at 19.19.16 (1).jpeg](/home/daytona/workspace/compressed-images/compressed_WhatsApp Image 2026-05-12 at 19.19.16 (1).jpeg) | 16.8 KB |
| [WhatsApp Image 2026-05-12 at 19.19.16.jpeg](/home/daytona/workspace/compressed-images/compressed_WhatsApp Image 2026-05-12 at 19.19.16.jpeg) | 17.3 KB |
| [WhatsApp Image 2026-05-12 at 19.19.15.jpeg](/home/daytona/workspace/compressed-images/compressed_WhatsApp Image 2026-05-12 at 19.19.15.jpeg) | 16.4 KB |
| [WhatsApp Image 2026-05-12 at 19.19.15 (1).jpeg](/home/daytona/workspace/compressed-images/compressed_WhatsApp Image 2026-05-12 at 19.19.15 (1).jpeg) | 17.6 KB |
I don't see the download link. Please give it properly.
cd /home/daytona/workspace/compressed-images && \ mv "compressed_WhatsApp Image 2026-05-12 at 19.19.16 (1).jpeg" compressed_img1.jpeg && \ mv "compressed_WhatsApp Image 2026-05-12 at 19.19.16.jpeg" compressed_img2.jpeg && \ mv "compressed_WhatsApp Image 2026-05-12 at 19.19.15.jpeg" compressed_img3.jpeg && \ mv "compressed_WhatsApp Image 2026-05-12 at 19.19.15 (1).jpeg" compressed_img4.jpeg && \ ls -lh compressed_*.jpeg
cd /home/daytona/workspace/compressed-images && python3 << 'EOF' import os, shutil mapping = { "compressed_WhatsApp Image 2026-05-12 at 19.19.16 (1).jpeg": "compressed_img1.jpeg", "compressed_WhatsApp Image 2026-05-12 at 19.19.16.jpeg": "compressed_img2.jpeg", "compressed_WhatsApp Image 2026-05-12 at 19.19.15.jpeg": "compressed_img3.jpeg", "compressed_WhatsApp Image 2026-05-12 at 19.19.15 (1).jpeg": "compressed_img4.jpeg", } for src, dst in mapping.items(): if os.path.exists(src): shutil.copy2(src, dst) print(f"Copied {src} -> {dst} ({os.path.getsize(dst)/1024:.1f} KB)") else: print(f"NOT FOUND: {src}") EOF
python3 << 'EOF' import os from PIL import Image urls = [ ("https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-16-1-1778594180060-kgljcs.jpeg", "/home/daytona/workspace/compressed-images/compressed_img1.jpeg"), ("https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-16-1778594180056-3ad6kl.jpeg", "/home/daytona/workspace/compressed-images/compressed_img2.jpeg"), ("https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-15-1778594180085-94a7ng.jpeg", "/home/daytona/workspace/compressed-images/compressed_img3.jpeg"), ("https://d361swluvexzqs.cloudfront.net/chats-attachments/WhatsApp-Image-2026-05-12-at-19-19-15-1-1778594180086-zrsa87.jpeg", "/home/daytona/workspace/compressed-images/compressed_img4.jpeg"), ] import urllib.request TARGET = 20 * 1024 for url, out_path in urls: tmp = out_path + "_tmp.jpg" urllib.request.urlretrieve(url, tmp) img = Image.open(tmp) w, h = img.size saved = False for quality in range(85, 0, -5): img.save(out_path, "JPEG", quality=quality, optimize=True) if os.path.getsize(out_path) < TARGET: print(f"{out_path}: quality={quality}, {os.path.getsize(out_path)/1024:.1f} KB") saved = True break if not saved: for scale in [0.5, 0.4, 0.3, 0.25, 0.2, 0.15]: resized = img.resize((int(w*scale), int(h*scale)), Image.LANCZOS) for quality in range(85, 5, -5): resized.save(out_path, "JPEG", quality=quality, optimize=True) if os.path.getsize(out_path) < TARGET: print(f"{out_path}: scale={scale}, quality={quality}, {os.path.getsize(out_path)/1024:.1f} KB") saved = True break if saved: break os.remove(tmp) EOF ls -lh /home/daytona/workspace/compressed-images/compressed_img*.jpeg
compressed img1
Image · JPEG
compressed img2
Image · JPEG
compressed img3
Image · JPEG
compressed img4
Image · JPEG