Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to add a text to image in php

<?php
/*
image.php
*/
    header("Content-type: image/jpeg");
    $imgPath = 'image.jpg';
    $image = imagecreatefromjpeg($imgPath);
    $color = imagecolorallocate($image, 255, 255, 255);
    $string = "http://recentsolutions.net";
    $fontSize = 3;
    $x = 115;
    $y = 185;
    imagestring($image, $fontSize, $x, $y, $string, $color);
    imagejpeg($image);
?>
Comment

add text to image and save php

<?php
// Set the content-type
header('Content-type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php read csv 
Php :: target class admin homecontroller does not exist laravel 8 
Php :: php 7 starts with 
Php :: php continue 
Php :: custom laravel auth 
Php :: convert scientific notation to decimal php 
Php :: php time() function 
Php :: multiple routes same controller laravel 
Php :: get numbers from string php 
Php :: login form in php 
Php :: string array to array in php 
Php :: get user information woocommerce 
Php :: laravel collection map 
Php :: laravel collection remove empty 
Php :: array filter multiple conditions php 
Php :: componentes blade laravel attributes merge 
Php :: laravel enum validation 
Php :: how to do a submit button in php without reloading the page 
Php :: php mongodb dll 
Php :: php loop 100 times 
Php :: base url dinamis codeigniter 
Php :: Warning: sprintf(): Too few arguments in /opt/lampp/htdocs/wordpress/wp-admin/includes/class-bulk-upgrader-skin.php on line 152 
Php :: php code for video upload 
Php :: php submit form in new tab 
Php :: read line by line php 
Php :: laravel download file from s3 
Php :: laravel query builder select 
Php :: guzzle get request 
Php :: laravel collection toQuery 
Php :: reply to wp_mail 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =