SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Want to save file that is watermarked with php/gd2 instead of display it

    I've adapted the following code to use to watermark images on my website:

    Code:
    <?php  
    
    header('content-type: image/jpeg'); 
    
    $wmarkloc =  "/home/site/public_html/tag.png";
    $imageloc = "/home/site/public_html/mainpic.jpg";
    
    $watermark = imagecreatefrompng($wmarkloc);  
      $red = imagecolorallocate($watermark, 255, 0, 0);
      imagecolortransparent($watermark, $red);
    
    $watermark_width = imagesx($watermark);  
    $watermark_height = imagesy($watermark);  
    $image = imagecreatetruecolor($watermark_width, $watermark_height);  
    $image = imagecreatefromjpeg($imageloc);  
    $size = getimagesize($imageloc);  
    imagecopymerge($image, $watermark, 0, 0, 0, 0, $watermark_width, $watermark_height, 100);  
    imagejpeg($image);
    
    imagedestroy($image);  
    imagedestroy($watermark);  
    
    ?>
    The problem is, I want to copy the image to a location on my server instead of display the image. I tried using copy($image,'/home/site/public_html/newpicture.jpg') but that did nothing. Also, like I said, I don't want to see the image, I just want a "success message" to be output so that I can make multiple images at once.

  2. #2
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, didn't realize you could use imagejpeg() to copy a file. Thanks!

  4. #4
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @jmusic, did you get it to work with imagejpeg?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •