PDA

View Full Version : یک مشکل در شکل گیری عکس



angel_boy013
جمعه 18 اسفند 1385, 20:11 عصر
این کد باید یک عکس با یک نوشته در وستش بیاره اما وقتی upload کردم نوشته نمیاد


<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE & ~E_STRICT");
// Set the content-type
header("Content-type: image/png");
include("fagd.php");
// Create the image

if(!$_GET[text])
{
$string = "NOTE";

}
else
$string = $_GET["text"];

$im = imagecreate(80, 40);


$bg = imagecolorallocate($im, 33, 254, -167);

$bgline = imagecolorallocate($im, 0, 0, 0);

imageline($im,0,6,90,6,$bgline); //line avale amodi
imageline($im,0,10,80,10,$bgline); //line 2vome amodi
imageline($im,0,14,80,14,$bgline); //line 3vome amodi

imageline($im,0,24,85,124,$bgline); //line 4vome amodi
imageline($im,20,88,22,58,$bgline); //line 5vome amodi


imageline($im,7,0,7,40,$bgline); //line avale ofoghi
imageline($im,12,0,12,40,$bgline); //line 2vome ofoghi
imageline($im,18,0,18,40,$bgline); //line 3vome ofoghi


imageline($im,28,34,43,40,$bgline); //line 4vome ofoghi
imageline($im,35,0,98,40,$bgline); //line 5vome ofoghi




// Create some colors
$white = imagecolorallocate($im, -33, 243, -167);
$grey = imagecolorallocate($im, 58, -128, 128);
$black = imagecolorallocate($im, 0, 0 , 0);


imagearc($im, 50, 100, 50, 150, 100, 100, $black);


// The text to draw
$text = fagd($string);
// Replace path by your own font path
$font = 'comic.ttf';

// Add some shadow to the text
imagettftext($im, 15, 20, -180, 250, $grey, $font, $text);

// Add the text
imagettftext($im, 15, 5, 10, 30 , $black, $font, $text);

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





?>

ali_sed
شنبه 26 اسفند 1385, 02:43 صبح
ایراد خاصی نداره فقط چک کن که فایلی را که include می کنی وجود داره (fagd.php) همچنین فونت استفاده شده را نیز روی سرور قرار بده و سرانجام چک کن که تابع fagd خروجی مناسبی را ارائه می دهد.کد زیر رو چک کردم ایرادی نداشت.



<?php
ini_set("error_reporting","E_ALL & ~E_NOTICE & ~E_STRICT");
// Set the content-type
header("Content-type: image/png");
include("fagd.php");
// Create the image

if(!$_GET[text])
{
$string = "NOTE";

}
else
$string = $_GET["text"];

$im = imagecreate(80, 40);


$bg = imagecolorallocate($im, 33, 254, -167);

$bgline = imagecolorallocate($im, 0, 0, 0);

imageline($im,0,6,90,6,$bgline); //line avale amodi
imageline($im,0,10,80,10,$bgline); //line 2vome amodi
imageline($im,0,14,80,14,$bgline); //line 3vome amodi

imageline($im,0,24,85,124,$bgline); //line 4vome amodi
imageline($im,20,88,22,58,$bgline); //line 5vome amodi


imageline($im,7,0,7,40,$bgline); //line avale ofoghi
imageline($im,12,0,12,40,$bgline); //line 2vome ofoghi
imageline($im,18,0,18,40,$bgline); //line 3vome ofoghi


imageline($im,28,34,43,40,$bgline); //line 4vome ofoghi
imageline($im,35,0,98,40,$bgline); //line 5vome ofoghi




// Create some colors
$white = imagecolorallocate($im, -33, 243, -167);
$grey = imagecolorallocate($im, 58, -128, 128);
$black = imagecolorallocate($im, 0, 0 , 0);


imagearc($im, 50, 100, 50, 150, 100, 100, $black);


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

// Add some shadow to the text
imagettftext($im, 15, 20, -180, 250, $grey, $font, $text);

// Add the text
imagettftext($im, 15, 5, 10, 30 , $black, $font, $text);

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





?>

Milad
شنبه 26 اسفند 1385, 08:16 صبح
مطمئن هستی extention ها لازم واسه این کار نصب کردی ؟
http://ir2.php.net/imagettftext
Write text to the image using TrueType fonts

angel_boy013
دوشنبه 28 اسفند 1385, 20:51 عصر
هم include هست هم فونت

ali_sed
سه شنبه 29 اسفند 1385, 13:53 عصر
چک کردی ببینی وب سروری که فایل ها را آپلود کردی از کتابخانه gd پشتیبانی می کنه یا نه.
دستور زیر را داخل یک فایل جداگانه بنویس و به سرور منتقل کن و اجرا کن بعد دنبال gd بگرد ببین داره یا نه.


<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>