1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with logo site's on images

Discussion in 'PHP' started by ludwig, Jan 10, 2010.

  1. #1
    I need either PHP script or some other maybe .htaccess code which does the following:

    • put a logo on site's images
    • i should be able to specify on images of which folder the logo should appear
    • i need to be able to specify the logo file, which in its turn can be transparent

    seems this is all.

    let me know if you have questions.

    please PM me your quote and how much time you need to make it.
     
    ludwig, Jan 10, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Can you ellaborate?
     
    danx10, Jan 10, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    MyVodaFone, Jan 10, 2010 IP
  4. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #4
    exactly

    here is a sample:
    [​IMG]

    since I am not into PHP I would like someone to help me and I am willing to pay for it. My site uses WordPress if that makes a change

    not sure how the sitepoint example does that but maybe that is what I need
     
    ludwig, Jan 10, 2010 IP
  5. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #5
    danx10, Jan 10, 2010 IP
    arba likes this.
  6. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #6
    ludwig, Jan 10, 2010 IP
  7. arba

    arba Active Member

    Messages:
    1
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    58
    #7
    it's possible to do with PHP for sure and that's not a hard thing to do.. firs you need to create a file namedfor ex. watermark.php and you will have to have the watermark image, say watermark.gif (it can also be *.jpg or *.png) in the same directory as watermark.php is.. if you want to have a transparent watermark then you will have to create a watermark image in GIF format and set the background transparent (actually it's possible to have a watermark image with transparent background in a PNG format)... so..
    1. first you open the watermark.php and copy and paste down the following code:
    <?php 
    
    header('content-type: image/jpeg'); //point the browser that we are going to pass an image file to is :)
    
    $imagesource =  $_GET['path']; //gets the image source that you are going to water mark
    $extension = substr($imagesource,strlen($imagesource)-4,4); //gets the extension of the image to determine which filter to use
    $extension = strtolower($extension); //saves the extension in $filetype variable
    
    //in next three steps it checks to see what is the extension 
    if($extension == ".gif")  $image = @imagecreatefromgif($imagesource);
    if($extension == ".jpg")  $image = @imagecreatefromjpeg($imagesource);  
    if($extension == ".png")  $image = @imagecreatefrompng($imagesource);  
    
    if (!$image) die(); //if nothing matches stops the script
    $watermark = @imagecreatefromgif('watermark.gif'); //you might have to change this line to $watermark = @imagecreatefrompng('watermark.png') or to jpeg if your watermark image is not gif
    $imagewidth = imagesx($image); //gets the image width of the picture you are going to watermark
    $imageheight = imagesy($image); //gets the height of the picture you are going to watermark  
    $watermarkwidth =  imagesx($watermark); //gets the width of the watermark image
    $watermarkheight =  imagesy($watermark); //gets the height of the watermark image
    
    //the followin two lines set the watermark location.. here it is set as you needed it.. right bottom corner
    $startwidth = (($imagewidth - $watermarkwidth) );
    $startheight = (($imageheight - $watermarkheight) );
    
    //put the watermark on the image and saves the watermarked image as a JPG file
    imagecopy($image, $watermark,  $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); 
    imagejpeg($image); 
    imagedestroy($image); 
    imagedestroy($watermark); 
    ?>
    PHP:
    that's all.. now a little about how to se it.
    $imagesource = $_GET['path']; gets the path of the image to be marked, so to pass the image path to this line you have to put it like this in your code:
    <img src="watermark.php?path=image_name.extension">
    where image_name.extension is the name of the file you want to watermark i.e. myimage.jpg.. in case when your image is in the folder other then script or even the page that needs to use the script is not in the same folder with script you can just change that line like this: <img src="script_folder_name/watermark.php?path=image_folder_name/image_name.extension">
    just remember to keep the watermark image and script together in the same folder.. sure you can not do that by changing the watermark image path here $watermark = @imagecreatefromgif('watermark.gif'); .. but it's more relyable to have them in the same folder ;)
    I have attached s sample with watermark image and image to be watermarked and script of course :)
    enjoy and let me know if that worked for you :)
     

    Attached Files:

    Last edited: Jan 11, 2010
    arba, Jan 11, 2010 IP
    ludwig likes this.
  8. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #8
    ludwig, Jan 12, 2010 IP