
113805
17.05.2017
Foto Upload und Default Text einfügen
Hallo zusammen
Ich bin auf der Suche nach einem Tool oder wie man das umsetzen kann.
http://eays.ee/idaho/
Ein User laded sein Bild hoch und es generiert mit seinem Bild einen Text und erstellt es Schwarzweiss auf das hochgeladene Bild.
Der User kann anschliessend das Bild dann herunterladen.
Hat jemand eine Idee?
Gruss
Ps. Ich habe es mal in den Webentwicklungs Bereich gelegt.
Ich bin auf der Suche nach einem Tool oder wie man das umsetzen kann.
http://eays.ee/idaho/
Ein User laded sein Bild hoch und es generiert mit seinem Bild einen Text und erstellt es Schwarzweiss auf das hochgeladene Bild.
Der User kann anschliessend das Bild dann herunterladen.
Hat jemand eine Idee?
Gruss
Ps. Ich habe es mal in den Webentwicklungs Bereich gelegt.
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 338071
Url: https://administrator.de/forum/foto-upload-und-default-text-einfuegen-338071.html
Ausgedruckt am: 23.04.2025 um 17:04 Uhr
12 Kommentare
Neuester Kommentar


Ich müsste eine Uploadfunktion erstellen mit PHP und danach das hochgeladene Bild verwenden um ein Text mit GD hinzuzufügen.
Genau, dann tu das.
Kannst du gerne:
(Achtung, hier wird eine ttf verwendet (Vorraussetzungen: GD und libfreefont6 library))
(Achtung, hier wird eine ttf verwendet (Vorraussetzungen: GD und libfreefont6 library))
<?php
function ProcessUploadedFile($upload_id, $arr_extensions){
try {
// check if undefined / multiple files etc.
if (!isset($_FILES[$upload_id]['error']) || is_array($_FILES[$upload_id]['error'])) {
throw new RuntimeException('Invalid files');
}
// check error value
switch ($_FILES[$upload_id]['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
throw new RuntimeException('No file sent.');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException('Exceeded filesize limit.');
default:
throw new RuntimeException('Unknown errors.');
}
// check mime type of file (don't rely on the mime-type of $_FILES!!)
$finfo = new finfo(FILEINFO_MIME_TYPE);
if (false === $ext = array_search($finfo->file($_FILES[$upload_id]['tmp_name']),$arr_extensions,true)) {
throw new RuntimeException('Invalid file format. Valid file formats: ' . implode(",",array_keys($arr_extensions)));
}
// create image ressource from file
$img = imagecreatefromjpeg($_FILES[$upload_id]['tmp_name']);
// use grayscale filter
imagefilter($img, IMG_FILTER_GRAYSCALE);
// define text to draw
$string = "Das ist ein Test";
// define color of text
$color = imagecolorallocate($img, 255, 98, 21);
// calculate bounding box of rendered text
$boxinfo = imageftbbox(80,0,"./script.ttf",$string);
// set x and x positions of textbox
$text_x = (imagesx($img)/2)-($boxinfo[2]/2);
$text_y = (imagesy($img)/2)-($boxinfo[7]/2);
// draw text to image
imagettftext($img,80,0,$text_x,$text_y,$color,"./script.ttf",$string);
// set header to return image
header("Content-Type: image/jpeg");
// return rendered image with quality of 90%
imagejpeg($img,NULL,90);
// destroy ressource
imagedestroy($img);
}catch (RuntimeException $ex){
echo $ex->getMessage();
}
}
if (isset($_POST['btnUpload'])){
$valid_ext = array('jpg' => 'image/jpeg');
ProcessUploadedFile('file_upload',$valid_ext);
}else{
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>File Upload</title>
</head>
<style type="text/css">
body{font-family:Verdana, Geneva, sans-serif;font-size:0.8em}
</style>
<body>
Choose your image (only *.jpg / max. 3MB)
<form enctype="multipart/form-data" action="" method="POST">
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="file_upload" accept="image/jpeg">
<input type="submit"name="btnUpload" value="Upload" >
</p>
</form>
</body>
</html>
<?php }?>

Zitat von @113805:
Finde diesen Beitrag gerade einfach völlig unnötig von Dir. Und wenn ich gerade Deine Kommentare ansehe bei anderen Themen geht das genauso weiter.
Nö, das Scoreboard sagt da was anderes, und guten Content liefere ich hier zur Genüge. Nur wollen die meisten hier sich alles aufs Silbertablett gelegt bekommen.Finde diesen Beitrag gerade einfach völlig unnötig von Dir. Und wenn ich gerade Deine Kommentare ansehe bei anderen Themen geht das genauso weiter.
Vielleicht möchte ich ja noch das Endresultat zeigen und noch weitere Fragen stellen bezüglich..?
bidde.