Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP GD watermark script produces blank watermark
    primarykey
    data
    text
    <p>I'm trying to add a watermark to images right after uploading them to my website, but it seems the watermark keeps coming out as a black object with no details. I believe the script is working a little bit because if it wasn't, I probably wouldn't see any kind of watermark or the script would fail.</p> <p>This is my script so far:</p> <pre><code>$watermark = imagecreatefrompng('preview-watermark.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($portfolio_preview_dir.'/'.$file); $size = getimagesize($portfolio_preview_dir.'/'.$file); $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, $portfolio_preview_dir.'/'.$file); imagedestroy($image); imagedestroy($watermark); </code></pre> <p>This is what it's producing. The shape of the watermark is correct, as the watermark is 325x37 pixels:</p> <p><img src="https://i.stack.imgur.com/EjOvE.png" alt="enter image description here"></p> <p>I have tried playing with the watermark image itself. My first attempt was to save the photoshop watermark (with transparent bg) using 'save for web' and selected 'PNG-24'. This didn't work, so I then saved it as a normal PNG (without 'save for web') and it still fails.</p> <p>I'm not sure whether it's the script or the image! Can somebody please share some knowledge with me and help fix this issue?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload