A reusable image management library that provides secure uploads, image optimization, compression, resizing, and watermarking using pure Core PHP.
PHP Image Manager is a lightweight and reusable image processing library developed using Core PHP and the GD Library.
It is designed for developers who need a production-ready solution for handling image uploads while keeping storage usage low and protecting images with watermarks.
Unlike framework-specific packages, this project can be integrated into any Core PHP application without external dependencies.
- β Secure Image Upload
- β Image Validation
- β JPEG / PNG / WebP Support
- β Automatic Image Optimization
- β Smart Image Compression
- β Image Resizing
- β Transparent PNG Watermark
- β Unique File Name Generation
- β MySQL Integration
- β Modular Architecture
- β Reusable Helper Functions
- β Production-Ready Code Structure
- β Easy Integration into Existing Projects
| Technology | Purpose |
|---|---|
| Core PHP | Backend |
| MySQL | Database |
| GD Library | Image Processing |
| HTML5 | Frontend |
| CSS3 | Styling |
| JavaScript | Optional UI Enhancements |
php-image-manager/
β
βββ assets/
β βββ watermark/
β βββ logo.png
β
βββ config/
β βββ config.php
β βββ database.php
β
βββ functions/
β βββ helper.php
β βββ validation.php
β βββ upload.php
β βββ image.php
β βββ watermark.php
β
βββ uploads/
β βββ optimized/
β βββ watermark/
β
βββ index.php
βββ upload_process.php
βββ image.sql
βββ README.md
User Uploads Image
β
βΌ
Validate Image
β
βΌ
Generate Secure Filename
β
βΌ
Resize Image (if required)
β
βΌ
Optimize & Compress Image
β
βΌ
Save Optimized Image
β
βΌ
Apply Watermark
β
βΌ
Save Watermarked Image
β
βΌ
Store Metadata in MySQL
β
βΌ
Success Response
git clone https://github.com/dev-amit-dots/php-image-manager.gitPlace the project inside your web server directory.
Example:
htdocs/
or
public_html/
CREATE DATABASE image_manager;Import
image.sql
Update
config/database.php
with your credentials.
$host = "localhost";
$user = "root";
$password = "";
$db = "image_manager";Place your transparent PNG logo inside
assets/watermark/logo.png
Open
http://localhost/php-image-manager/
| Column | Description |
|---|---|
| id | Primary Key |
| image_name | Original Generated Name |
| optimized_image | Optimized Image Path |
| watermark_image | Watermarked Image Path |
| image_size | File Size |
| image_type | MIME Type |
| created_at | Upload Timestamp |
- Allowed file type validation
- MIME type verification
- Maximum file size restriction
- Upload error handling
- Secure filename generation
- SQL Injection prevention
- Directory traversal protection
- Invalid image detection
- Automatic compression
- Automatic optimization
- Aspect ratio maintained
- Resize oversized images
- Watermark support
- PNG transparency support
- JPEG optimization
- WebP support
Many PHP projects simply upload images without optimizing or protecting them.
This library solves common problems by:
- Reducing storage usage
- Improving website performance
- Protecting images with watermarks
- Organizing uploaded files
- Providing reusable code for future projects
- CRM Systems
- CMS Platforms
- E-commerce Websites
- Portfolio Websites
- Blog Systems
- Property Listing Platforms
- School Management Systems
- Gallery Applications
- Custom Admin Panels
- Drag & Drop Upload
- Multiple Image Upload
- AJAX Upload Support
- Image Cropping
- Image Rotation
- Thumbnail Generation
- EXIF Orientation Fix
- AVIF Support
- Bulk Watermark Processing
- REST API
- Amazon S3 Storage
- Cloudflare R2 Support
- Image Metadata Viewer
Contributions are welcome.
If you have suggestions, bug fixes, or new features, feel free to:
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
Amit Tiwari
Backend Developer | Core PHP | Laravel | Python | Django
GitHub: https://github.com/dev-amit-dots GitHub: https://github.com/amittiwari-dev
LinkedIn: https://linkedin.com/in/amit-tiwari-2866-dev