Tuesday, September 25, 2012

Add Image watermark Over another Image PHP


Adding watermark is very help full. Add Image Watermark with original image is also help to protect our images here is my solution to Add Water Mark in PHP

Use the following Images

original_image.jpg




watermark_image.png

water mark image

Prepare an transparent image with exact same size of the original image. Transparent PNG with Text by overlap original image to create a final watermark added image.

<?php
// Original Image Path
$image= "images/original_image.jpg";  

header("Content-type: image/jpeg");
header("Content-Disposition: inline; filename=$image");

switch (TRUE) {
case stristr($image,'jpg') :
$photoImage = ImageCreateFromJPEG("$image");
break;
case stristr($image,'gif') :
$photoImage = ImageCreateFromGIF("$image");
break;
case stristr($image,'png') :
$photoImage = ImageCreateFromPNG("$image");
break;
}

ImageAlphaBlending($photoImage, true); 

// Same Size PNG Watermark Image with Transparency
$logoImage = ImageCreateFromPNG("watermark_image.png"); 
$logoW = ImageSX($logoImage); 
$logoH = ImageSY($logoImage); 

// were you see the two 1's this is the offset from the top-left hand corner!
ImageCopy($photoImage, $logoImage, 1, 1, 0, 0, $logoW, $logoH); 

imagejpeg($photoImage);
// if you want to save add the following line
imagejpeg($photoImage,"images/final.jpg");

ImageDestroy($photoImage); 
ImageDestroy($logoImage); 

?>



Login with Yahoo Account


Website login with Yahoo account been posted at :
Website Login with Yahoo Account in my previous post, yahoo openid identify url been changed.

please use the following new OpenID URL for yahoo in order to work.


NEW Yahoo OpenID URL:

http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds
<?php session_start();
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'require/openid.php';

try {
    # Change 'localhost' to your domain name.
    $openid = new LightOpenID('demos.w3lessons.com');
 
  $openid->required = array(
  'namePerson',
  'namePerson/first',
  'namePerson/last',
  'contact/email',
  );

    if(!$openid->mode) {
  
 if(@$_GET['auth']=="google")
    {
  $_SESSION['auth']="Google";
        $openid->identity = 'https://www.google.com/accounts/o8/id';
        header('Location: ' . $openid->authUrl());
 }elseif(@$_GET['auth']=="yahoo")
 {
  $_SESSION['auth']="Yahoo";
$openid->identity ='http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds';
  header("Location:".$openid->authUrl());
 }

    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
   $external_login=$openid->getAttributes();
   $_SESSION['name']=$external_login['namePerson/first']." ".$external_login['namePerson/last'];
   $_SESSION['email']=$external_login['contact/email'];
   header("Location:account-home.php");
   exit();
   
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}
?>



View the Updated New Demo & Download

Download This Script     Live Demo     Download Script