PHP Image Filter & Effects Tool
Build a PHP-powered image editor that applies filters like grayscale, sepia, blur, brightness, and contrast using GD library.
PHPGD LibraryImage ProcessingFilters
Overview
Create a web-based image editor using PHP's GD library. Upload an image and apply filters like grayscale, sepia, blur, and more.
Filter Processor (apply.php)
php
<?php
session_start();
$source = $_SESSION['original'] ?? null;
$filter = $_GET['filter'] ?? 'none';
if (!$source || !file_exists($source)) { header('Location: index.php'); exit; }
$img = imagecreatefromstring(file_get_contents($source));
switch ($filter) {
case 'grayscale': imagefilter($img, IMG_FILTER_GRAYSCALE); break;
case 'sepia':
imagefilter($img, IMG_FILTER_GRAYSCALE);
imagefilter($img, IMG_FILTER_COLORIZE, 100, 50, 0);
break;
case 'negative': imagefilter($img, IMG_FILTER_NEGATE); break;
case 'blur': for ($i = 0; $i < 5; $i++) imagefilter($img, IMG_FILTER_GAUSSIAN_BLUR); break;
case 'emboss': imagefilter($img, IMG_FILTER_EMBOSS); break;
case 'sharpen': imagefilter($img, IMG_FILTER_MEAN_REMOVAL); break;
case 'brightness': imagefilter($img, IMG_FILTER_BRIGHTNESS, 40); break;
case 'contrast': imagefilter($img, IMG_FILTER_CONTRAST, -50); break;
}
$output = 'uploads/filtered_' . basename($source);
imagepng($img, $output);
imagedestroy($img);
$_SESSION['uploaded'] = $output;
header('Location: index.php');
?>Main Page (index.php)
php
<?php
session_start();
$filters = ['none'=>'Original','grayscale'=>'Grayscale','sepia'=>'Sepia','negative'=>'Negative','blur'=>'Blur','emboss'=>'Emboss','sharpen'=>'Sharpen','brightness'=>'Bright','contrast'=>'Contrast'];
$uploaded = $_SESSION['uploaded'] ?? null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image Filter Tool</title>
<style>
body { background: #0a0a23; color: #fff; font-family: sans-serif; padding: 2rem; text-align: center; }
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin: 1.5rem 0; }
.filters a { padding: 8px 16px; background: #1a1a3e; border-radius: 8px; color: #fff; text-decoration: none; transition: all 0.2s; }
.filters a:hover { background: #6c63ff; }
.preview img { max-width: 600px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
</style>
</head>
<body>
<h1>������️ Image Filter Tool</h1>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" required>
<button type="submit">Upload</button>
</form>
<?php if ($uploaded): ?>
<div class="filters">
<?php foreach ($filters as $key => $label): ?>
<a href="apply.php?filter=<?= $key ?>"><?= $label ?></a>
<?php endforeach; ?>
</div>
<div class="preview"><img src="<?= htmlspecialchars($uploaded) ?>" alt="Preview"></div>
<?php endif; ?>
</body>
</html>Technologies
- PHP GD Library — image filters, color manipulation - PHP Sessions — upload state management - CSS — dark theme, responsive layout
Related Projects
PHPApr 27, 2026
Analog Clock with PHP & CSS
Build a beautiful real-time analog clock using PHP for time calculation and CSS for the rotating hands and dial.
PHPCSSAnimationClock
Read more → Source
PHPApr 27, 2026
Animated Loading Spinners Gallery in PHP
Create a gallery of 10+ beautiful CSS loading spinner animations served dynamically through PHP.
PHPCSSAnimationSpinners
Read more → Source
PHPApr 27, 2026
PHP Color Palette Generator
Generate beautiful random color palettes with hex codes, RGB values, and one-click copy — all powered by PHP.
PHPCSSColorsDesign Tool
Read more → Source
Comments (0)
No comments yet. Be the first to comment!