0
我在這裏是新的,所以我有一個自定義函數來計算imagettftext()的寬度和高度,但是當我包含包含該函數的文件時,它只顯示破損形象,我不知道是什麼導致了它....沒有圖像顯示:php gd自定義函數
這是我last.php文件(它理應與文本顯示圖像)
<?php
include ('function-location.php');
$location = new lokasyon;
$x = $location->text_location_x();
$y = $location->text_location_y();
$img = imagecreatefromjpeg('\xampp\htdocs\1\q.jpg');
$font_size = 10;
$white = imagecolorallocate($img, 195, 195, 195);
$font_path = 'C:\Windows\Fonts\Arial.ttf';
$text = "Fashion.com";
$angle = 0 ;
echo $x." & ".$y;
// Y X
imagettftext($img, $font_size, 0, $y, $x, $white, $font_path, $text);
header('Content-type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
?>
這是我的功能location.php
<?php
class lokasyon{
public $location;
public $font_size;
public $img;
public function __construct(){
}
function text_location_x($x=''){
$location = $_POST['Location'];
$img = imagecreatefromjpeg('\xampp\htdocs\1\q.jpg');
$font_size = 10;
if ($location == "Top Left"){
$x = (imagesx($img)-$font_size);
return $x;
}
elseif ($location == "Top Right"){
$x = (imagesx($img)-$font_size);
return $x;
}
elseif ($location == "Bottom Left"){
$x = 0;
return $x;
}
else{
$x =(imagesx($img)-$font_size);
return $x;
}
}
function text_location_y($y=''){
$location = $_POST['Location'];
$img = imagecreatefromjpeg('\xampp\htdocs\1\q.jpg');
$font_size = 10;
if ($location == "Top Left"){
$y = 0;
return $y;
}
elseif ($location == "Top Right"){
$y = 0;
return $y;
}
elseif ($location == "Bottom Left"){
$y = (imagesy($img)-$font_size);
return $y;
}
else{
$y =(imagesy($img)-$font_size);
return $y;
}
}
}
?>
我是新在這個..