Answers for "php create image png from url"

PHP
0

php save image from url to folder

You should be able to use file_get_contents for this one. In order to use an URL with file_get_contents make sure allow_url_fopen is enabled in you php.ini file.

define('DIRECTORY', '/home/user/uploads');

$content = file_get_contents('http://anothersite/images/goods.jpg');
file_put_contents(DIRECTORY . '/image.jpg', $content);
Make sure that you have write permission to the directory where you want to store the image; to make the folder writable you could do this:

chmod +w /home/users/uploads
Posted by: Guest on March-11-2021
2

php create an image

<?php
header("Content-Type: image/png");//change the php file to an image
$im = @imagecreate(110, 20)
    or die("Cannot Initialize new GD image stream");//creates an image with the resolution x:110 y:20 
$background_color = imagecolorallocate($im, 0, 0, 0);//create an color with RGB
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);//draws text to the image with the font:1 xpos:5 ypos:5 
imagepng($im);//sends the image data to the user
imagedestroy($im);//destroys the image from the server
?>
Posted by: Guest on April-08-2020

Browse Popular Code Answers by Language