Autor Zpráva
Jack Finger
Profil
proč mi tenhle kód vyhodí jen fotku, ale nikdy ne text natištěný na fotce?


$filename = "IMG_3636.jpg";
$copypath = "test.jpg";
list($OrigWidth, $OrigHeight) = getimagesize($filename);
$pw = $OrigWidth / 120;
$ph = $OrigHeight / 90;
if ($pw > $ph)
$p = $pw;
else
$p = $ph;
if ($p < 1)
$p = 1;
$NewWidth = (int)$OrigWidth / $p;
$NewHeight = (int)$OrigHeight / $p;
$image_p = imagecreatetruecolor($NewWidth, $NewHeight);
$image = imagecreatefromjpeg($filename);
$black = ImageColorAllocate($image, 0, 0, 0);
$white = ImageColorAllocate($image, 255, 255, 255);
$string = "text k natisteni";
//$start_x = 10;
//$start_y = 35;
ImageString($image, 2, 1, 1, $string, $white);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $NewWidth, $NewHeight, $OrigWidth, $OrigHeight);
imagejpeg($image_p,$copypath, 100);
Ni7R0
Profil
Text tam je, ale při tom zmenšení není vidět. Zkuste zvětšit ty dělitele u $pw a $ph a uvidíte.
dracek
Profil
Zkus vypsat text až po resamplování.
Jack Finger
Profil
díky moc, vypadá to že to funguje!!
Jack Finger
Profil
tak teď to mám takhle:


function resize2big($filename, $copypath){
list($OrigWidth, $OrigHeight) = getimagesize($filename);
$pw = $OrigWidth / 400;
$ph = $OrigHeight / 300;
if ($pw > $ph)
$p = $pw;
else
$p = $ph;
if ($p < 1)
$p = 1;
$NewWidth = (int)$OrigWidth / $p;
$NewHeight = (int)$OrigHeight / $p;
$image_p = imagecreatetruecolor($NewWidth, $NewHeight);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $NewWidth, $NewHeight, $OrigWidth, $OrigHeight);
$color = ImageColorAllocate($image_p, 191, 189, 185);
$string = "text k natisteni";
$start_x = 20;
$start_y = 160;
ImageTTFText($image_p, 30, 0, $start_x, $start_y, $color, "./arial.ttf", $string);
if(imagejpeg($image_p,$copypath, 100))
return true;
else
return false;
}


jede to v poho, akorát mám problém s tím, že když je fotka na výšku (např.: 448x598px), tak to text hodí až jakoby "od začátku té fotky", tzn, že začíná kdesi uprostřed a vede do neznáma... nemá někdo zkušenost nebo radu o kterou by se podělil?

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0