Hello
Recently I tried to create user signatures via PHP GD.
I am using PHP GD class and everythign works great but I am facing a problem.
When I’m trying to add image from the database (database value for example: “http://www.someremoteurl.com/image.png”) it doesn’t work and show me blank instead of the signature.
This is my signature php file:
<?php
use PHPImageWorkshop\\ImageWorkshop as ImageWorkshop;
require_once('GD_Includes/PHPImageWorkshop/Exception/ImageWorkshopBaseException.php');
require_once('GD_Includes/PHPImageWorkshop/Exception/ImageWorkshopException.php');
require_once('GD_Includes/PHPImageWorkshop/Core/Exception/ImageWorkshopLayerException.php');
require_once('GD_Includes/PHPImageWorkshop/Core/ImageWorkshopLib.php');
require_once('GD_Includes/PHPImageWorkshop/Core/ImageWorkshopLayer.php');
require_once('GD_Includes/PHPImageWorkshop/ImageWorkshop.php');
include("sigconfig.php");
$User = mysql_real_escape_string($_GET["user"]);
$query = mysql_query("SELECT * from user WHERE id = '".$User."'") or die(mysql_error());
if(mysql_num_rows($query) >=1) {
$row = mysql_fetch_array($query);
function utf8_strrev($str){
if (!preg_match('/^[\\w\\d\\s.,-]*$/', $str)) {
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}
else {
return $str;
}
}
$Username = ''.$row["first_name"].'';
//Favorites!
$getfav = mysql_query('SELECT title,artist,img FROM favorites WHERE user_id = "'.$row['id'].'"');
$fav1 = mysql_fetch_assoc($getfav);
$fav1title = $fav1['title'];
$fav1artist = $fav1['artist'];
$fav1img = $fav1['img'];
$fav2 = mysql_fetch_assoc($getfav);
$fav2title = $fav2['title'];
$fav2artist = $fav2['artist'];
$fav2img = $fav2['img'];
$fav3 = mysql_fetch_assoc($getfav);
$fav3title = $fav3['title'];
$fav3artist = $fav3['artist'];
$fav3img = $fav3['img'];
$Base_Pic = "GD_Includes/CardNone.png";
$BaseLayer = ImageWorkshop::initFromPath($Base_Pic);
$text_username = $Username;
// Font Normal
$fontPath = "GD_Includes/arial.ttf"; // Song
$fontPath2 = "GD_Includes/PoetsenOne-Regular.ttf"; // Artist
$fontSize = 14; // Artist
$fontSize2 = 12; // Song
$fontColor = "FFFFFF";
$textRotation = 0;
$text = ImageWorkshop::initTextLayer($text_username, $fontPath, $fontSize, $fontColor, $textRotation, $backgroundColor);
//Songs
$song1a = ImageWorkshop::initTextLayer($fav1artist, $fontPath2, $fontSize, $fontColor, $textRotation, $backgroundColor);
$song1t = ImageWorkshop::initTextLayer($fav1title, $fontPath, $fontSize2, $fontColor, $textRotation, $backgroundColor);
$BaseLayer->addLayerOnTop($text, 20, 11, "LT");
$BaseLayer->addLayerOnTop($song1a, 50, 45, "LT");
$BaseLayer->addLayerOnTop($song1t, 55, 70, "LT");
//Show Result
$image = $BaseLayer->getResult();
header('Content-type: image/png');
header('Content-Disposition: filename="card.png"');
imagepng($image, null, 8); // We choose to show a PNG (quality of 8 on a scale of 0 to 9)
exit;
}
else {
echo "NOT FOUND";
}
?>
My goal is to add an image which stored in the parameter “$fav1img” near the text.
Any help?