SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    232
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Smile GD image guestion

    Through what function i can add small banner on a photo ?

    For example in my script for now i use imagettftext()

    This is some example
    PHP Code:
    $image_name $_POST['imagefile'];
    $font_size "18"
    $font_path "AARDV.TTF"
    $text "Bt-Club.Org";    
    $image imagecreatefromjpeg($_FILES['imagefile']['tmp_name']);    
    $black imagecolorallocate($image0,0,0);   
    $Width "10";
    $Height imagesy($image);
    imagettftext ($image$font_size0$Width$Height-10$black$font_path$text);
    header("Content-type: image/jpeg");
    imagejpeg($image,$cachefile,100);
    imagedestroy($image); 
    for now the results



    and i want to do like this



    thanks for help

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Have a look through: http://php.net/manual/en/function.imagecopymerge.php
    It takes part of an image and merges it with another. Sounds pretty much what you are after
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had used the following code for watermarking the image. It might be helpful to you.
    Code php:
    header("Content-type: image/jpeg");
    $original_file = "theimage.jpg";
     
    $margin = 5;
     
    $watermark = imagecreatefrompng('watermark.png');
    $w = imagesx($watermark);
    $h = imagesy($watermark);
     
    $image = imagecreatefromjpeg($original_file);
    $width = imagesx($image);
    $height = imagesy($image);
     
    $dest_x = $margin;
    $dest_y = $margin;
     
    imagecopy($image, $watermark, $margin, $margin, 0, 0, $w-$margin, $height-$margin);
    #output image
    imagejpeg($image);
     
    imagedestroy($image);
    imagedestroy($watermark);

    It will merge two images. watermark.png image will be merged/watermarked ontheimage.jpg.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Addict Smolf3d's Avatar
    Join Date
    Aug 2004
    Location
    russia
    Posts
    232
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for a prompt replys

    Now work with me

    PHP Code:
    header("Content-type: image/jpeg");
    $original_file "theimage.jpg"
    $margin 0
    $watermark imagecreatefrompng('watermark.png');
    $w imagesx($watermark);
    $h imagesy($watermark); 
    $image imagecreatefromjpeg($original_file);
    $width 0;
    $height imagesy($image); 
    $dest_x $margin;
    $dest_y $margin
    $cachefile = ("images/name.jpg");
    imagecopy($image$watermark$width$height-3000$w-$margin$height-$margin);
    #output image
    imagejpeg($image,$cachefile,100);
    imagedestroy($image);
    imagedestroy($watermark); 

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    tidy bit of code there rajug
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •