Watermarking Images using PHP with Source Code
Seeing one’s work altered without permission can be frustrating as discovering your work on blogs that are void of any credit. The first response for most photographers is to watermark their images, ensuring that their logo or website graces every image that hits the internet.
This Web Application that I am posting is built to create a watermark on an image. The source code that I will share will help you to understand how does watermark in an image is done using PHP. To watermark an image in this web app, first, you must select an image in the given file input in a form. Then, just simply click the "Watermark Image" button to put a watermark in your selected image. The watermark that I have used in this web is an Image with a transparent background, sample watermark images are located inside the "img" folder. The source code itself automatically resizes the watermark image to fit in the image. After the process is being done the finished product will be displayed in the "Watermarked Image" Panel and the image with the watermark is downloadable. If you want a different watermark, you can create your own using Photoshop. This script is coded in PHP 7.1.8 and I don't know if this script will run smoothly on older versions of PHP
Read more about this article at this link
Code Features
- Put watermark on Images
- Input type file REQUIRED
- Check if a Directory Exists
- Check if a Directory is Empty
- Create a Directory is not Exists
- Display Live system date and time
- Open New Tab using anchor tag (< a >)
How to Run
Requirements:
- Download and Install any local web server such as XAMPP/WAMP to run a PHP script.
- You need GD Library Installed on your Server. Usually, this is already installed in a virtual server such as XAMPP, make sure the gd extension is already uncommented in your
php.ini
. - Download the provided source code zip file.( download button is located below )
Installation/Setup
- Open your XAMPP/WAMP's Control Panel and start the "Apache".
- Extract the downloaded source code file.
- If you are using XAMPP, copy the extracted source code folder and paste it into the XAMPP's "htdocs" directory. And If you are using WAMP, paste it into the "www" directory.
- Browse the Web App in a browser. i.e. http://localhost/watermark
DEMO
I hope this will help you and you will learn something useful with this Watermarking an Image Web App in PHP.
Enjoy :)
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Comments
GD Image Library
Error
Add new comment
- Add new comment
- 1305 views