���� ������
�������� ������ ������ �� ����������� ��������� php �� ������� ��������� ������� ��������� � �������� ����������� GD. ������� ������������ PHP http://php.net, ��������� ��������� ����� ������ �������, ���������� ���������, ���������, ������������ ��������.
�������� ������
�������� ��������� ���������� � public_html. � ������ ������� ��� ��������� ������ ��� ����������, ����� ������������� ��� � ����������� .php.1. ������ ��������
������������ ������ ������� (piramida):��������� � ������� php.net ������� �������, ������������ � �������. �������� ��������� ������� ����� �������, ����� ���������� ����������� ��������: ����� - ����� �������, �������� - ������� ����, ������ - ������� �����������.<?php $im = imagecreatetruecolor(200, 200); $blue = imagecolorallocate($im, 0, 0, 255); $red = imagecolorallocate($im, 255, 0, 0); $green = imagecolorallocate($im, 0, 255, 0); imagefilledrectangle ($im, 20, 20, 60,60, $red); //������� ������������� imagefilledellipse($im, 50, 160, 30, 30, $green); //������� ���� // ������ ����� ��� ������������ $values = array( 150, 110, // Point 1 (x, y) 140, 130, // Point 2 (x, y) 160, 130, // Point 3 (x, y) ); // ��������� ������������ imagefilledpolygon($im, $values, 3, $blue); // ���������� header("Content-type: image/png"); imagepng($im); // ������������ ������ imagedestroy($im); ?>
2. �����������
������������ ������ ������� (demotivator):���������� �������������� ��������� ������ ���������, ���������� ������ ������� � ������ ����������. ������ ������� "HELLO WORLD" ������� ������� ���������� (UTF8) "��� �� ���������". ��������: � �������� ���������� ������� ��� ������� imagestring() �� ������ ������������� ������. ��� ������� �������� ����������:<?php // ��� ����������� - jpg header('Content-Type: image/jpeg'); // �������� ����� � ��������� � ��������� ��� � ��������������� $im $im = imagecreatefromjpeg("./1.jpg"); // �������� ����� ������ $text_color = imagecolorallocate($im, 255, 65, 91); // ���������� ������ ������ ������� (��������!) 5 � ���������� 5, 5 imagestring($im, 5, 250, 350, "HELLO WORLD", $text_color); // ����� ����������� � ������� imagejpeg($im); // ������������ ������ imagedestroy($im); ?>
- ������� ������ ������� imagettftext(), ������ ���������� � ������ ������������� (��. php.net ����� �������� �������).
- ��������� ���� � �������� 1.jpg � ���� � TrueType ������� arial.ttf � ������� ����������.
- ������������ �� ������ 1 ������� ������ "��� �� ���������", ����� ��������� ���������: ������_������=36; ���������� (x, y)=(65, 380); ���� ������ - ����� (R,G,B=255,255,255).
- � ������� ������� imagejpeg() ��������� ����� ������������� ����������� � ���� demotivator.jpg
3. ����� ���
������������ ������ ������� (graycat):��������� ������������� �������� cat.jpg � �����-����� ������. ��� ����� ���������� ��������� � ����������� ������� imagefilter() � ��������������� �������� (����� �������������� ����� php.net). ������ ������ �������� �� ����� ��������������� ����������� � ���������� ��� � ���� graycat.jpg<?php $im = imagecreatefromjpeg("./cat.jpg"); // ������������� ��� ����������� header('content-type: image/jpeg'); // ����� ����������� �� ����� imagejpeg($im); // ������� ������ imagedestroy($im); ?>