So, what I want is where user can upload image, a PHP script will add watermark to it,a nd the pic will be hosted on imgur using imgur API
Adding watermark to the image and hosting it to imgur is not the problem, but the problem is: to upload image to imgur, we must pass the base64 of the picture, and I can't fetch the pic that has been given watermark by PHP script using file_get_contents
and fopen
, it always gives error
Someone please help me with the problem so I can fetch the image, encode it to base64
That's all
UPDATE:
Just to tell you, i used the function to open the PHP file DIRECTLY without saving the pic to disk first, for some reason i can't save the image to the disk, that's why i use imgur
UPDATE AGAIN:
here's my code:
<?php
header('Content-type: image/png');
$image = $_GET['url'];
$imagesize = getimagesize($image);
$img = imagecreatetruecolor($imagesize[0], $imagesize[1] + 50);
imagecopy($img, imagecreatefrompng($image), 0, 0, 0, 0, $imagesize[0], $imagesize[1]);
$string = "Some wild watermarks";
$font = "font.ttf";
$fontSize="30";
$textColor = imagecolorallocate($img, 255,255,255);
$x=7;
$y=$imagesize[1] + 42;
imagettftext($img,$fontSize,0,$x,$y,$textColor,$font,$string);
imagepng($img);
?>
Here's the error i got:
Using file_get_contents
:
Warning: file_get_contents(watermark.php?url=roughdesign.png) [function.file-get-contents]: failed to open stream: Result too large in URL
Using fopen
:
Warning: fopen(watermark.php?url=roughdesign.png) [function.fopen]: failed to open stream: Result too large in URL
Warning: filesize() [function.filesize]: stat failed for URL
Warning: fread(): supplied argument is not a valid stream resource in URL