Im Resizer
WordPress Image Resizer Plugin
by Sachin Solanki · github.com/tachukadi/im-resizer · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/tachukadi/im-resizer/archive/refs/heads/main.zipIm Resizer - WordPress Image Optimization Plugin
A powerful WordPress plugin to automatically resize images on upload and batch process existing images to save hosting space.
Features
- Auto Resize on Upload: Toggle to automatically resize images when uploaded to WordPress media library
- Batch Processing: Scan and process all images in your uploads directory
- PHP-FPM Optimized: Configurable delays and request limiting to prevent server overload
- Configurable Settings:
- Set maximum width and height
- Adjust JPEG quality
- Configure batch processing size (5-50 images per batch)
- Set delay between batches (1-10 seconds)
- Limit concurrent requests (1-3, default: 1)
- Real-time Processing Log: See exactly what's happening with each image
- Smart Scanning: Recursively scans all subdirectories for images
- Multiple Image Formats: Supports JPG, JPEG, PNG, BMP, and GIF
- No Timeouts: Processes images in batches to prevent script timeouts
- Memory Efficient: Optimized to handle large image libraries
- Error Handling: Continues processing even if individual images fail
- Overwrites Originals: Saves hosting space by not keeping backups
- Request Locking: Prevents concurrent processing to protect server resources
Installation
Method 1: Manual Upload
- Download the plugin files
- Create a folder named
im-resizerin your/wp-content/plugins/directory - Upload all plugin files to
/wp-content/plugins/im-resizer/ - Go to WordPress Admin → Plugins
- Activate "Im Resizer"
Method 2: ZIP Upload
- Package all files into a ZIP file named
im-resizer.zip - Go to WordPress Admin → Plugins → Add New
- Click "Upload Plugin"
- Choose the ZIP file and click "Install Now"
- Activate the plugin
File Structure
im-resizer/
├── im-resizer.php # Main plugin file
├── js/
│ └── admin.js # Admin JavaScript
├── css/
│ └── admin.css # Admin styles
└── README.md # This file
Usage
Initial Setup
-
Go to WordPress Admin → Im Resizer
-
Configure your settings:
- Max Width: Maximum image width in pixels (default: 1920)
- Max Height: Maximum image height in pixels (default: 1920)
- JPEG Quality: Compression quality 1-100 (default: 85)
- Batch Size: How many images to process at once (default: 20)
- Auto Resize on Upload: Toggle ON to automatically resize new uploads
-
Click "Save Settings"
Batch Processing Existing Images
-
Click the "Scan Images" button
- Plugin will scan all folders and subfolders
- Shows total images found
- Shows how many need resizing
- Displays total size of oversized images
-
Review the scan results in the stats panel
-
Click the "Process Images" button
- Processes images in batches
- Shows real-time log of each image processed
- Displays original and new dimensions/sizes
- Shows progress percentage
- Updates processed/failed counters
-
Use "Stop Processing" button to pause processing after current batch
Real-time Log
The processing log shows:
- Timestamp of each action
- Filename being processed
- Original dimensions and file size
- New dimensions and file size
- Success/failure status with color coding:
- Green: Successfully processed
- Red: Failed to process
- Orange: Warnings
- Blue: Information messages
Technical Details
Image Processing
- Uses PHP GD library for image manipulation
- Maintains aspect ratio when resizing
- Preserves transparency for PNG and GIF images
- Supports JPEG, PNG, GIF, and BMP formats
- Overwrites original files (no backups created)
Performance
- Processes images in configurable batches (10-100)
- Sets unlimited execution time to prevent timeouts
- Increases memory limit to 512MB for processing
- Small delays between batches to prevent server overload
- Continues processing even if individual images fail
Security
- Nonce verification for all AJAX requests
- Capability checks (requires 'manage_options')
- Sanitized and validated inputs
- Escapes all outputs
Settings Explained
Max Width/Height
The maximum dimensions for any image. Images larger than these dimensions will be proportionally resized to fit within these limits while maintaining aspect ratio.
JPEG Quality
Compression quality for JPEG images:
- 1-40: Low quality, small file size
- 50-70: Medium quality, balanced
- 80-95: High quality, larger file size
- 96-100: Maximum quality, minimal compression
Batch Size
Number of images to process in each batch:
- Smaller (5-10): Best for limited server resources and low PHP-FPM limits
- Medium (15-20): Good balance for most servers
- Larger (30-50): Faster processing on powerful servers
Important for PHP-FPM: Keep this lower (5-15) if your server has PHP-FPM limits of 5 or fewer processes.
Batch Delay
Time to wait between processing batches:
- 1 second: Faster processing, more server load
- 2-3 seconds: Recommended for most servers
- 5-10 seconds: Safest for servers with strict resource limits
Critical for PHP-FPM: This delay ensures your server doesn't hit PHP-FPM process limits. With a 2-3 second delay and batch size of 10, the plugin will never exceed 1-2 concurrent PHP-FPM processes.
Max Concurrent Requests
Maximum number of simultaneous processing requests:
- 1 (Safest): Only one batch processes at a time - Recommended for PHP-FPM limit of 5
- 2: Two batches can process simultaneously
- 3: Three batches can process simultaneously
For PHP-FPM servers: Always keep this at 1 to ensure you never exceed your PHP-FPM process limit. The plugin uses request locking to enforce this limit.
Auto Resize on Upload
When enabled:
- Automatically resizes images when uploaded to media library
- Applies settings immediately on upload
- Saves hosting space from the start
- No need to batch process new uploads
PHP-FPM Optimization
Why These Settings Matter
If your server has a PHP-FPM limit (commonly 5-10 processes), aggressive batch processing can exhaust all available PHP-FPM workers, causing:
- Website slowdown or unavailability
- 502/504 errors for other users
- Failed batch processing
Recommended Settings for PHP-FPM Limit of 5:
- Batch Size: 10-15 images
- Batch Delay: 2-3 seconds
- Max Concurrent Requests: 1 (enforced by default)
This ensures:
- Each batch uses only 1 PHP-FPM process
- 2-3 second gaps allow other requests to process
- Website remains responsive during batch processing
- No PHP-FPM pool exhaustion
How It Works:
- Request Locking: PHP transient locks prevent concurrent batch processing
- JavaScript Queue: Only one AJAX request processes at a time
- Configurable Delays: Waits between batches to free up PHP-FPM workers
- Small Image Delays: 0.1 second pause between individual images in a batch
Troubleshooting
Images not processing
- Check PHP GD library is installed (
php -m | grep gd) - Verify file permissions (files should be writable)
- Increase batch size to smaller number
- Check error log for specific issues
Script timeout
- Plugin is designed to prevent timeouts
- If still occurring, reduce batch size
- Check PHP max_execution_time setting
Memory issues
- Plugin increases memory to 512MB
- If still failing, increase batch size to smaller number
- Check server memory limits
Images look bad quality
- Increase JPEG Quality setting (try 90-95)
- PNG/GIF quality is always maximum
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- PHP GD library installed
- Write permissions on uploads directory
Support
For issues or feature requests, contact the developer or check the plugin documentation.
Version History
1.0.0
- Initial release
- Auto resize on upload
- Batch scanning and processing
- Real-time processing log
- Support for JPG, PNG, GIF, BMP
- Configurable settings
- No timeout processing
- PHP-FPM optimization features:
- Request locking to prevent concurrent processing
- Configurable batch delays (1-10 seconds)
- Adjustable batch sizes (5-50 images)
- Max concurrent request limiting
- JavaScript request queue system
- Server-side transient locks
- 0.1 second delays between individual images
License
GPL v2 or later
Author
SS - WordPress Developer
- Website: https://masterkey.bm
- Advanced site: https://advanced.bm
Important Notes:
- This plugin overwrites original images without creating backups. Make sure you have a backup of your media library before running batch processing for the first time.
- For servers with PHP-FPM limits: Use the recommended settings (Batch Size: 10-15, Batch Delay: 2-3 seconds, Max Concurrent: 1) to prevent server overload and maintain website availability during processing.