Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
* * * * * 1 votes

Watermark Your Image With Simple Php Script


42 replies to this topic

#26 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 12 October 2007 - 03:00 AM

How to create watermark on pdf files in php? can you provide me php script please.............
thank you!

-siva rama krishna

#27 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windowsthe good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 01 November 2007 - 04:36 AM

View PostTrap FeedBacker, on Oct 11 2007, 09:00 PM, said:

How to create watermark on pdf files in php? can you provide me php script please.............
thank you!

-siva rama krishna

I use a pdf creation software named cutepdf to enhance my pdf output. Actually, i have the cutepdf paid version, might be the paid version which has all the nice features, but I think the basic, free version can 'stamp' pdf pages, too.

http://www.cutepdf.com/

#28 bishoujo

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 545 posts
  • Gender:Female
  • Interests:Beauty, Health, Technology, Travel, Gaming, Manga, Anime, Movies, Books, Cooking
  • myCENT:1.87

Posted 01 November 2007 - 02:19 PM

Great! can't wait to try this out! Thank you!

#29 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 04 December 2007 - 11:50 AM

Hello people thank you for this script and as I made one that works for me for watermarking multiple picture on upload .

<?php

$watermarkPath = '/root_path_to_png_watermark/'.$watermark_name.'.png';
$target = '/root_path_to_where_upload_after_watermarking/'.$uploaded_picture_name;
$quality = "100";
$imagesource = '/root_path_to_where_upload_after_watermarking/'.$uploaded_picture_name;
$filetype = substr($imagesource,strlen($imagesource)-4,4);
$filetype = strtolower($filetype);
$watermarkType = substr($watermarkPath,strlen($watermarkPath)-4,4);
$watermarkType = strtolower($watermarkType);

if($filetype == ".gif")
$image = @imagecreatefromgif($imagesource);
else
if($filetype == ".jpg" || $filetype == "jpeg")
$image = @imagecreatefromjpeg($imagesource);
else
if($filetype == ".png")
$image = @imagecreatefrompng($imagesource);
else
die("a murit nu am scos imaginea");

if(!$image)
die("a murit nu avem imagine");

if($watermarkType == ".gif")
$watermark = @imagecreatefromgif($watermarkPath);
else
if($watermarkType == ".png")
$watermark = @imagecreatefrompng($watermarkPath);
else
die("a murit $watermark nu e");

if(!$watermark)
die("a murit lipsa watermark");

$imagewidth = imagesx($image);
$imageheight = imagesy($image);
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = (($imagewidth - $watermarkwidth)/to);
$startheight = (($imageheight - $watermarkheight)/to);
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
imagejpeg($image,$target,$quality);
imagedestroy($image);
imagedestroy($watermark);
?>



Hope this works for you.

-Costin Iordache

#30 Sleffler

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 04 January 2008 - 07:40 PM

Thanks for posting the code, I am using it on most of my site.
I was wondering if you guys might have an idea on how to pull watermarking off on a href tag. (click a thumbnail to display the large image)

Here is what I tried

<a href="watermark.php?path=images/image1.jpg"><img src="images/image1_thumbnail.jpg" />

Clicking the link yields the raw gd output similar to this

Quote

�JFIF�������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality �C�    $.' ",#(7),01444'9=82<.342�C  2!!22222222222222222222222222222222222222222222222222�y "������������ ����}�!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������� ���w�!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz� ��?�ReI0#L #w̐)DŒu83J�2mC4h L\/qڬ{hF! 

Thanks,

Sean

#31 rvalkass

    apt-get moo

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,107 posts
  • Gender:Male
  • Location:Devon, England
  • Interests:At the moment, Physics mainly!
  • myCENT:69.42
  • Spam Patrol

Posted 04 January 2008 - 07:47 PM

You need to add this line to the top of your PHP file, to tell the browser to treat the output as an image:

header("Content-type: image/jpeg");

You can also change jpeg to another image type, if you generate a different image type.

#32 Sleffler

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 04 January 2008 - 08:06 PM

View Postrvalkass, on Jan 4 2008, 12:47 PM, said:

You need to add this line to the top of your PHP file, to tell the browser to treat the output as an image:

header("Content-type: image/jpeg");

You can also change jpeg to another image type, if you generate a different image type.


Thank you very much!

#33 Zenten

    Newbie

  • Kontributors
  • Pip
  • 4 posts

Posted 04 January 2008 - 08:37 PM

Maybe there is way to add the watermark using a combination of php and perl so that it can rotate based on page refresh. I'll try to post something if I can figure it out.

#34 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 31 May 2008 - 08:44 PM

Overwrite image
Watermark Your Image With Simple Php Script

Hi guys, I'm new to PHP. I have this problem on overwriting the image after watermarking the image from the user directory.

I'm not sure is it this part that will overwrite the image or to other directory (imagejpeg($image,$target,$quality);).
But I tried this, it doesn't work.

Lot of help...
Cyrus

#35 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 06 July 2008 - 10:53 AM

How to copy uploading image to our website
Watermark Your Image With Simple Php Script

I have successfully make watermark and resize image,
But how to copy image thats has we make watermark to our website?

-reply by nababan




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users