Skip to content

About

A production-ready Core PHP image management library with secure image uploads, optimization, resizing, compression, watermarking, and MySQL integration using the PHP GD Library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Έ PHP Image Manager

A Production-Ready Image Upload, Optimization & Watermark Library Built with Core PHP

A reusable image management library that provides secure uploads, image optimization, compression, resizing, and watermarking using pure Core PHP.


✨ Overview

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.


πŸš€ Features

  • βœ… 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

πŸ›  Tech Stack

Technology Purpose
Core PHP Backend
MySQL Database
GD Library Image Processing
HTML5 Frontend
CSS3 Styling
JavaScript Optional UI Enhancements

πŸ“‚ Project Structure

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

βš™οΈ Workflow

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

πŸ“¦ Installation

1. Clone the Repository

git clone https://github.com/dev-amit-dots/php-image-manager.git

2. Move the Project

Place the project inside your web server directory.

Example:

htdocs/

or

public_html/

3. Create Database

CREATE DATABASE image_manager;

Import

image.sql

4. Configure Database

Update

config/database.php

with your credentials.

$host = "localhost";
$user = "root";
$password = "";
$db = "image_manager";

5. Add Watermark Logo

Place your transparent PNG logo inside

assets/watermark/logo.png

6. Start Uploading

Open

http://localhost/php-image-manager/

πŸ“ Database Schema

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

πŸ”’ Security Features

  • 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

πŸ“ˆ Image Processing Features

  • Automatic compression
  • Automatic optimization
  • Aspect ratio maintained
  • Resize oversized images
  • Watermark support
  • PNG transparency support
  • JPEG optimization
  • WebP support

🎯 Why This Project?

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

πŸ“Œ Use Cases

  • CRM Systems
  • CMS Platforms
  • E-commerce Websites
  • Portfolio Websites
  • Blog Systems
  • Property Listing Platforms
  • School Management Systems
  • Gallery Applications
  • Custom Admin Panels

🧩 Future Roadmap

  • 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

🀝 Contributing

Contributions are welcome.

If you have suggestions, bug fixes, or new features, feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

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


⭐ If you found this project helpful, consider giving it a star!

Happy Coding! πŸš€

About

A production-ready Core PHP image management library with secure image uploads, optimization, resizing, compression, watermarking, and MySQL integration using the PHP GD Library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages