SitePoint Sponsor

User Tag List

Page 2 of 6 FirstFirst 123456 LastLast
Results 26 to 50 of 138
  1. #26
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any of the gd dudes still around?

    I've still got this black bg haning around... I wonder if its my png file.

    I tried adding:

    PHP Code:
    $black ImageColorAllocate ($watermark000);
     
     
    ImageColorTransparent($watermark $black); 
    but it didn't change a thing.

    Thanks again dudes.

    d3.

  2. #27
    John P.
    SitePoint Community Guest
    I was having the same problem with the background. Turns out my issue was that the sample code has the merge percentage at 100. I set this to 20 and it made a nice transparent version of my PNG as advertised!

    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);

  3. #28
    Claudio Heidel
    SitePoint Community Guest
    I fix it to run with transparent watermarks

    <?php
    header('content-type: image/jpeg');
    $watermark = imagecreatefrompng('watermark.png');
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);
    $image = imagecreatetruecolor($watermark_width, $watermark_height);
    $image = imagecreatefromjpeg($_GET['photo_file']);
    $size = getimagesize($_GET['photo_file']);
    $dest_x = $size[0] - $watermark_width - 5;
    $dest_y = $size[1] - $watermark_height - 5;
    imagecopy($image, $watermark, $dest_x , $dest_y, 0, 0, $watermark_width, $watermark_height);
    imagejpeg($image);
    imagedestroy($image);
    imagedestroy($watermark);
    ?>

    Claudio Heidel
    www.heidel.com.ar

  4. #29
    SitePoint Member
    Join Date
    Dec 2004
    Location
    france
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can anyone help me out here?

    I have tried this code as it seems to be just what I want but i keep getting this error

    imagecreatefrompng(): gd-png: fatal libpng error: Incompatible libpng version in application and library

    I have php version 4.3.4 and GD 2.0.15 ( compatible) installed on the server I am using.

    many thanks

    Ratty

  5. #30
    Gytis
    SitePoint Community Guest
    Just one problem - a watermarked picture is at reduced quality... I checked this with 1024x768 Porsche wallpaper. I use GD 2.0.15. Anyone knows how to preserve original image quality?

    Gytis
    www.nfstuning.com

  6. #31
    Anonymous
    SitePoint Community Guest
    Why i have this error ?? :

    Warning: Cannot modify header information - headers already sent by (output started at /home/cirque2/public_html/aucirque/o/water.php:4) in /home/cirque2/public_html/aucirque/o/water.php on line 32
    ................................

    I want only put a design :'(

  7. #32
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Huddersfield, United Kingdom
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I keep getting this error

    <br />
    <b>Fatal error</b>: Call to undefined function: imagecreatefrompng() in <b>/root/public_html/watermark.php3</b> on line <b>5</b><br />

    anyone else getting a error like this?

  8. #33
    Chaos Engine
    SitePoint Community Guest
    The imagejpeg($image); takes three values. If you change it to imagejpeg($image,'',100); it will keep your quality.

  9. #34
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are getting an error which says imagecreatefrompng() your server most likely does not have GD 2.0 installed.

  10. #35
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would anyone care for a function to use during image upload?
    SK

  11. #36
    Rob
    SitePoint Community Guest
    A function during upload would be great...

  12. #37
    Saus
    SitePoint Community Guest
    Can I know how I can implement a transparent background for the png watermark I use? Currently the png is merged as a rectangular block.

  13. #38
    N8
    SitePoint Community Guest
    use png-8. GD has errors if using png-24

  14. #39
    Gizmo
    SitePoint Community Guest
    getimagesize is a PHP-builtin function. imagesx and imagesy are not.

    for the rest, a very good article!

  15. #40
    eddy
    SitePoint Community Guest
    this does not work on my site.. where do you put the code and do you ahve to edit the <img tag

  16. #41
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    working alone but not working with gd
    what should we do ?

  17. #42
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats how my orignal code looks like


    /////////// ////Snapshot creation //////////////////////////////

    if (!file_exists("$site_dir/" . "snap_$userfile_name"))
    {
    $thumb->size_auto(416);
    $thumb->jpeg_quality(60);
    $thumb->save("$site_dir/snap_$userfile_name", $gd_version);

    $image_src = $site_dir . "snap_$userfile_name";

    header('content-type: image/jpeg');

    $watermark = imagecreatefrompng('watermark.png');
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);
    $image = imagecreatetruecolor($watermark_width, $watermark_height);
    $image = imagecreatefromjpeg($image_src);
    $size = getimagesize($image_src);
    $dest_x = $size[0] - $watermark_width - 5;
    $dest_y = $size[1] - $watermark_height - 5;
    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
    imagejpeg($image);
    imagedestroy($image);
    imagedestroy($watermark);

    $thumb=new thumbnail("$site_dir/$userfile_name");

    }
    PR6 Web Directory

    PR5 Category and Subcategory Pages

  18. #43
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thumbnail is successfully created but with no watermark and that what i get after uploading

    JFIF>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality C    $.' ",#(7),01444'9=82<.342C  2!!222222222222222222222222222222222222222222222222228 "
    PR6 Web Directory

    PR5 Category and Subcategory Pages

  19. #44
    Bose-Einstein-Kondensat
    SitePoint Community Guest
    @inversec80:

    try fixing your apache's mime-type forcing.
    it seems apache thinks "it's a xxx.php-file so force it to text/html" or something like that, because
    header('Content-Type: image/jpeg');
    should say "show as jpeg".

    But maybe it's wrong to type "content-type" (small case!!). So pay attention to that. :)

  20. #45
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YOu can use 24-bit transparencu with this code if you change one line of the code

    PHP Code:
    imagecopymarged($image$watermark$dest_x$dest_y00$watermark_width$watermark_height100); 
    to
    PHP Code:
    imagecopyresampled($image$watermark$dest_x$dest_y00$watermark_width$watermark_height$watermark_width$watermark_height); 
    This works fine. If you wanna know more about this function
    imagecopyresampled()

  21. #46
    Anonymous
    SitePoint Community Guest
    good

  22. #47
    SitePoint Zealot ngi112's Avatar
    Join Date
    May 2005
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the tutorial!

  23. #48
    lkbb
    SitePoint Community Guest
    thanks man

  24. #49
    Anonymous
    SitePoint Community Guest
    I've been looking for this kind of tutorial for a while, yet this one like
    any one else gives me the foolowing error:

    Wend outputting to the browser I should use -->
    header('Content-Type: image/jpeg');
    ... yet when I try to save the image from the browser (Save image as...) the
    image is saved as 'script_name.php'.

    Is there any way to go around this?

    I'm storing all the original images in a folder and the watermarked ones in
    another.
    I'm watermarking them on the fly and calling the <img src.....> that has
    been watermarked. I've chossen this way because then I'm able to chanse the
    logo whenever I wan't.
    I can't go on like this 'cause of the server space I've bought is to small
    to have duplicates.

    Thank's.
    Sorry about the English.

  25. #50
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    complete newb needing more info

    I need some assistance in implementing this. Anyone have a sample zip?

    I took the code from the article and saved it as watermark.php.

    Next, I opened photoshop and created a watermark.png file that just had my name. I placed it in the same directory as watermark.php.

    I placed a sample jpg img in that directory as well, and called it car.jpg.

    Then I created an html page (test.html, placed in the same directory) to call the image. I did it like this:

    <img src="watermark.php?image=car.jpg" alt="This is a test" />

    When I view test.html, all I see is my alt tags. Obviously, I'm attempting to implement this completely wrong, but I didn't see where to do that correctly. Can someone address that for me? I would definitely appreciate it. - Tony


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
  •