46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
|
|
abstract class phImaginator_Write extends phImaginator_Universal implements phImaginator_Module {
|
|
|
|
protected static $runCollected = false;
|
|
|
|
|
|
public static function text($text, $position_horizontal, $position_vertical, $rotation = 0) {
|
|
$image_data =& parent::getCurrentResource();
|
|
|
|
self::writeText($image_data, $text, $position_horizontal, $position_vertical, $rotation);
|
|
}
|
|
|
|
|
|
public static function fileInfo($position_horizontal, $position_vertical) {
|
|
$image_data =& parent::getCurrentResource();
|
|
|
|
$text = $image_data['fileinfo']['basename'] . ' (' . $image_data['width'] . ' x ' . $image_data['height'] . ')';
|
|
|
|
self::writeText($image_data, $text, $position_horizontal, $position_vertical);
|
|
}
|
|
|
|
|
|
private static function writeText(&$image_data, $text, $x, $y, $rotation = 0) {
|
|
$fontColor = parent::transparency($image_data['resource'], parent::getFontColor(), parent::getFontOpacity());
|
|
|
|
$fontSize = parent::getFontSize();
|
|
$fontFile = parent::getFontFile();
|
|
|
|
$tboxSize = imagettfbbox($fontSize, $rotation, $fontFile, $text);
|
|
|
|
$textPos = parent::getElementPositions($x, $y, $image_data, abs($tboxSize[4]), abs($tboxSize[5]));
|
|
|
|
imagettftext($image_data['resource'], $fontSize, $rotation, $textPos['x'], $textPos['y'] + abs($tboxSize[5]), $fontColor, $fontFile, $text);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|