Created
January 16, 2019 07:54
-
-
Save surajitbasak109/395f6bac982da7d1f90a765816af2c4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ob_start(); | |
// Load the stamp and the photo to apply the watermark to | |
$logoImage = imagecreatefrompng('stamp.png'); | |
$image = imagecreatefromjpeg('photo.jpg'); | |
$new_name = 'abcdefg.jpg'; | |
// $image = imagecreatefromjpeg( $new_name ); | |
// $logoImage = imagecreatefrompng( $watermarksrc ); | |
imagealphablending( $logoImage, true ); | |
$imageWidth=imagesx($image); | |
$imageHeight=imagesy($image); | |
$logoWidth=imagesx($logoImage); | |
$logoHeight=imagesy($logoImage); | |
imagecopy( | |
$image, | |
$logoImage, | |
$imageWidth-$logoWidth, $imageHeight-$logoHeight, | |
0, 0, | |
$logoWidth, $logoHeight ); | |
// Set type of image and send the output | |
// header("Content-type: image/jpeg"); | |
imagepng( $image ); | |
$img_data = ob_get_contents (); | |
ob_end_clean (); | |
$b_img = base64_encode( $img_data );/*display image with watermark */ | |
// @imagepng( $image, $new_name );/* save image with watermark */ | |
// Release memory | |
imagedestroy( $image ); | |
imagedestroy( $imageLogo ); | |
?> | |
<img src="data:image/jpeg;base64,<?php echo $b_img; ?>" alt="Image"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment