Created
November 18, 2025 04:05
-
-
Save jongan69/707909ee6b726218754a0e7fc4cd8611 to your computer and use it in GitHub Desktop.
Bash script for optimizing logo in public folder of app
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 characters
| #!/bin/bash | |
| # Script to optimize logo.png for web performance | |
| # This script requires ImageMagick or similar tools | |
| LOGO_FILE="public/logo.png" | |
| OUTPUT_FILE="public/logo-optimized.png" | |
| echo "Optimizing logo.png for web performance..." | |
| # Check if ImageMagick is installed | |
| if command -v convert &> /dev/null; then | |
| echo "Using ImageMagick to optimize logo..." | |
| # Resize to max 192x192 (largest needed size) | |
| # Compress with quality 85 | |
| # Strip metadata | |
| convert "$LOGO_FILE" \ | |
| -resize 192x192\> \ | |
| -quality 85 \ | |
| -strip \ | |
| "$OUTPUT_FILE" | |
| # Get file sizes | |
| ORIGINAL_SIZE=$(ls -lh "$LOGO_FILE" | awk '{print $5}') | |
| OPTIMIZED_SIZE=$(ls -lh "$OUTPUT_FILE" | awk '{print $5}') | |
| echo "✅ Optimization complete!" | |
| echo "Original: $ORIGINAL_SIZE" | |
| echo "Optimized: $OPTIMIZED_SIZE" | |
| echo "" | |
| echo "Next steps:" | |
| echo "1. Review logo-optimized.png" | |
| echo "2. If satisfied, replace logo.png: mv public/logo-optimized.png public/logo.png" | |
| echo "3. Or use online tools: https://tinypng.com/ or https://squoosh.app/" | |
| elif command -v sips &> /dev/null; then | |
| # macOS built-in tool | |
| echo "Using macOS sips to optimize logo..." | |
| sips -Z 192 -s format png "$LOGO_FILE" --out "$OUTPUT_FILE" | |
| ORIGINAL_SIZE=$(ls -lh "$LOGO_FILE" | awk '{print $5}') | |
| OPTIMIZED_SIZE=$(ls -lh "$OUTPUT_FILE" | awk '{print $5}') | |
| echo "✅ Optimization complete!" | |
| echo "Original: $ORIGINAL_SIZE" | |
| echo "Optimized: $OPTIMIZED_SIZE" | |
| echo "" | |
| echo "⚠️ Note: sips doesn't compress as well. Consider using online tools:" | |
| echo " - https://tinypng.com/" | |
| echo " - https://squoosh.app/" | |
| echo " Target: <50KB file size" | |
| else | |
| echo "❌ ImageMagick or sips not found." | |
| echo "" | |
| echo "Please use one of these methods to optimize logo.png:" | |
| echo "" | |
| echo "Option 1: Online Tools (Recommended)" | |
| echo " 1. Go to https://tinypng.com/ or https://squoosh.app/" | |
| echo " 2. Upload public/logo.png" | |
| echo " 3. Resize to max 192x192px" | |
| echo " 4. Download and replace public/logo.png" | |
| echo " 5. Target: <50KB file size" | |
| echo "" | |
| echo "Option 2: Install ImageMagick" | |
| echo " macOS: brew install imagemagick" | |
| echo " Linux: sudo apt-get install imagemagick" | |
| echo " Then run this script again" | |
| echo "" | |
| echo "Option 3: Manual optimization" | |
| echo " - Open logo.png in image editor" | |
| echo " - Resize to 192x192px maximum" | |
| echo " - Export as PNG with compression" | |
| echo " - Target: <50KB file size" | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment