TechSansar
  • Startups
    • Tech Events
      • Submit Tech Events in Nepal
  • Services
    • Shop
    • Web hosting Features
    • Projects initiated by Team TechSansar
    • Windows Apps developed by Team TechSansar
  • Top Posts
    • ICT Organizations in Nepal
    • Top Websites in Nepal
    • Trending Topics related to Nepal
    • Wi-Fi Access Directory Nepal
    • SEO Guide to Nepalese Bloggers – नेपाली ब्लगरहरुलाई SEO सम्बन्धि सुझावहरु
  • Market
    • LG TV Prices
    • Galaxy Tablet Prices
    • Samsung TV Prices
  • Categories
    • Gadgets
    • Nepali IT
    • Telecom
    • Freebies
    • QnA
      • Ask a Question
      • नेपाली संस्करण
No Result
View All Result
Social icon element need JNews Essential plugin to be activated.
TechSansar
  • Startups
    • Tech Events
      • Submit Tech Events in Nepal
  • Services
    • Shop
    • Web hosting Features
    • Projects initiated by Team TechSansar
    • Windows Apps developed by Team TechSansar
  • Top Posts
    • ICT Organizations in Nepal
    • Top Websites in Nepal
    • Trending Topics related to Nepal
    • Wi-Fi Access Directory Nepal
    • SEO Guide to Nepalese Bloggers – नेपाली ब्लगरहरुलाई SEO सम्बन्धि सुझावहरु
  • Market
    • LG TV Prices
    • Galaxy Tablet Prices
    • Samsung TV Prices
  • Categories
    • Gadgets
    • Nepali IT
    • Telecom
    • Freebies
    • QnA
      • Ask a Question
      • नेपाली संस्करण
No Result
View All Result
TechSansar

Create Watermark of image using PHP

5 years ago
in How To, Software, Tips & Tricks, Tutorials
Reading Time: 4 mins read
0
watermark using php

Creating a watermark for normal individuals is not an easy task. For a professional designer, it is an easier task to do. Let’s create a system that will help you create an image with a watermark in just a minute of time using PHP. We decide to use PHP as it is one of the most popular programming language in the context of Nepal.

Doing it on the local machine requires xampp or wamp or lamp or mamp. The purpose of using one of these is they provide PHP and Apache server to work locally.

Step 1: Loading the images

$logo = imagecreatefrompng('logo.png');
$image = imagecreatefrompng('image.png');
here we are using the PHP function imagecreatefrompng, which is used to create a new image from the given URL. In our context, the two images are in the same directory of the index.php file.

Step 2: Getting the height and width along with the margins

$margin_right = 500;
$margin_bottom = 350;
$img_width = imagesx($logo);
$img_height = imagesy($logo);
here we are using another PHP function called imagesx and imagesy.  imagesx has been used to get the image width and imagesy to get the image height.

Step 3: Positioning the image and aligning the logo as per the calculation

imagecopy($image, $logo, imagesx($image ) - $img_width - $margin_right, imagesy($image) - $img_height - 
$margin_bottom, 0, 0, imagesx($logo), imagesy($logo));

here we are positioning the image that we want to use as a watermark over another.

Step 4: Output and freeing memory

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

here we are displaying the output and freeing the memory that has been held during the operation.

Related Post

How to Control a Linear Actuator with Arduino

Develop free Android Apps without coding in Nepal

Why should entrepreneur strictly learn to code? – Programming Concepts

What's behind that alluring fancy curtain of Facebook?

Results

Images that have been used:

watermark imagewatermark logo

Output Generated:

watermark output

Source Code

Next Post
fix for “Sorry, another account from your organization is already signed in on this computer.”

Fix for “Sorry, another account from your organization is already signed in on this computer.”

No Result
View All Result

Recent Posts

  • Great! Nagarik App now supports Vehicle Tax and Bluebook Info #NagarikApp
  • 👍 Nepal moves 15 spots up in Global Cybersecurity Index 2021
  • Brave Search is here – offers independent privacy search #SearchEngine #BraveSearch
  • Windows 11 – what we know so far about Microsoft’s Windows 11?
  • How to reduce background noise during Microsoft Teams or Zoom meetings
  • What is VoLTE & how to activate VoLTE for Nepal Telecom mobile SIM
  • ICT Initiatives announced during National ICT Day 2078 #NationalICTDay
  • Nagarik App is out of beta, introduces Nagarik profile QR scanner & more features
  • Samsung’s Flagship Phones Prices in Nepal
  • 6 simple yet effect ways to speed up your Windows 10 computer

Recent Comments

  • Dewlance Hosting on Top Websites in Nepal
  • Suman Singh on Basic Core ICT Indicators
  • Dinesh Guragai on Huawei Authorised Dealers, Distributors & Service Centers in Kathmandu, Nepal
  • Anup Thapa on All Nepali Fonts – download & install in Windows, Mac & Ubuntu
  • Dhiraj singh on Authorized distributors & Service center of Dell laptops in Nepal

Listen to TechSansar Podcast

Categories

Recently published

  • Great! Nagarik App now supports Vehicle Tax and Bluebook Info #NagarikApp
  • 👍 Nepal moves 15 spots up in Global Cybersecurity Index 2021
  • Brave Search is here – offers independent privacy search #SearchEngine #BraveSearch
  • Windows 11 – what we know so far about Microsoft’s Windows 11?
  • How to reduce background noise during Microsoft Teams or Zoom meetings
No Result
View All Result
Call us: +1 234 JEG THEME
No Result
View All Result
  • QnA Platform
  • Gadgets
  • Tech News
  • Tips & Tricks
  • About us
  • ICT in Nepal
  • Market

With ❤ from Nepal