Milspotters forum -> Leeuwarden movements database -> Foto's insturen tbv de Database
![]() | Foto's insturen tbv de Database![]() Aantal posts: 4049x Ranking: MilSpotter PB sturen | Website bezoeken |
<?php
$margin_x = 10;
$margin_y = 10;
$img = imagecreatefromjpeg("a10.jpg");
$img_width = imagesx($img);
$img_height = imagesy($img);
$text_color = imagecolorallocate($img, 255, 255, 255);
$text_font = "./WeekdaysRomanSlant.ttf";
$text_string = "© 2009 Gerben Wijnja";
$text_size = 12;
$text_bbox = imagettfbbox($text_size, 0, $text_font, $text_string);
$text_left = $text_bbox[0];
$text_bottom = $text_bbox[1];
$text_right = $text_bbox[4];
$text_top = $text_bbox[5];
$text_width = $text_right - $text_left;
$text_height = $text_bottom - $text_top;
$text_x = $img_width - $margin_x - $text_width - $text_left;
$text_y = $img_height - $margin_y - $text_bottom;
imagettftext($img, $text_size, 0, $text_x, $text_y, $text_color, $text_font, $text_string);
imagejpeg($img);
imagedestroy($img);
?>
<?php
function draw_copyrighted_image(
$image_filename, $font_filename,
$margin_x, $margin_y,
$text_string, $text_size, $text_position,
$text_r, $text_g, $text_b)
{
$img = imagecreatefromjpeg($image_filename);
$img_width = imagesx($img);
$img_height = imagesy($img);
$text_color = imagecolorallocate($img, $text_r, $text_g, $text_b);
$text_bbox = imagettfbbox($text_size, 0, $font_filename, $text_string);
$text_left = $text_bbox[0];
$text_bottom = $text_bbox[1];
$text_right = $text_bbox[4];
$text_top = $text_bbox[5];
$x_left = $margin_x - $text_left;
$x_center = ($img_width - ($text_right - $text_left)) / 2 - $text_left;
$x_right = $img_width - $text_right - $margin_x;
$y_top = $margin_y - $text_top;
$y_bottom = $img_height - $text_bottom - $margin_y;
switch($text_position) {
case "topleft": $text_x = $x_left; $text_y = $y_top; break;
case "topcenter": $text_x = $x_center; $text_y = $y_top; break;
case "topright": $text_x = $x_right; $text_y = $y_top; break;
case "bottomleft": $text_x = $x_left; $text_y = $y_bottom; break;
case "bottomcenter": $text_x = $x_center; $text_y = $y_bottom; break;
case "bottomright": $text_x = $x_right; $text_y = $y_bottom; break;
}
imagettftext($img, $text_size, 0, $text_x, $text_y, $text_color, $font_filename, $text_string);
imagejpeg($img);
imagedestroy($img);
}
$image_filename = "a10.jpg";
$font_filename = "./WeekdaysRomanSlant.ttf";
$margin_x = 10;
$margin_y = 10;
$text_string = "© 2009 Gerben Wijnja";
$text_size = 14;
$text_position = "topright";
$red = 128;
$green = 0;
$blue = 255;
draw_copyrighted_image($image_filename, $font_filename, $margin_x, $margin_y, $text_string, $text_size, $text_position, $red, $green, $blue);
?>