[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Как загрузить и обработать несколько изображений?
Tures
Не получается обходить циклом, полученный массив и обрабатывать по-отдельности, пробовал через for - ничего не выводилось.

<?PHP

$image_path = "9lesson.png";
$font_path = "OpenSans-Regular.ttf"; // в пикселях
//$water_mark_text_1 = "9";

if(isset($_POST["usertext"])){
$water_mark_text_2 = $_POST["usertext"];
}
if(empty($_POST["usertext"])){
$water_mark_text_2 = "Ваш текст";
}

if(isset($_POST["usersize"])){
$font_size = $_POST["usersize"];
}
if(empty($_POST["usersize"])){
$font_size = 9;
}

function watermark_image($oldimage_name, $new_image_name){
global $image_path;
list($owidth,$oheight) = getimagesize($oldimage_name);
$width = $height = 300;
$im = imagecreatetruecolor($width, $height);
$img_src = imagecreatefromjpeg($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
$watermark = imagecreatefrompng($image_path);
list($w_width, $w_height) = getimagesize($image_path);
$pos_x = $width - $w_width;
$pos_y = $height - $w_height;
imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
imagejpeg($im, $new_image_name, 100);
imagedestroy($im);
unlink($oldimage_name);
return true;
}


function watermark_text($oldimage_name, $new_image_name){
global $font_path, $font_size, $water_mark_text_1, $water_mark_text_2;
list($owidth,$oheight) = getimagesize($oldimage_name);
$width = $owidth;
$height = $oheight;
$image = imagecreatetruecolor($width, $height);
$image_src = imagecreatefromjpeg($oldimage_name);
imagecopyresampled($image, $image_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
$black = imagecolorallocate($image, 0, 0, 0);
$blue = imagecolorallocate($image, 79, 166, 185);
$white = imagecolorallocate($image, 255, 255, 255);
// imagettftext($image, $font_size, 0, 30, 190, $black, $font_path, $water_mark_text_1);
// Цвета текста

if($_POST["usertextcolor"] == "blue"){
$font_color = $blue;
}

if($_POST["usertextcolor"] == "white"){
$font_color = $white;
}

if($_POST["usertextcolor"] == "black"){
$font_color = $black;
}


//
imagettftext($image, $oheight*2/100, 90, $owidth-9, $oheight-7, $font_color, $font_path, $water_mark_text_2);
imagejpeg($image, $new_image_name, 100);
imagedestroy($image);
unlink($oldimage_name);
return true;
}
$demo_image= "";

if(isset($_POST['createmark']) and $_POST['createmark'] == "Submit"){
$path = "uploads/";
$valid_formats = array("jpg", "bmp", "jpeg", "png");
$name = $_FILES['imgfile']['name'];
if(strlen($name))
{
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$valid_formats)&& $_FILES['imgfile']['size'] <= 17*1024*1024)
{
$upload_status = move_uploaded_file($_FILES['imgfile']['tmp_name'], $path.$_FILES['imgfile']['name']);
if($upload_status){
$new_name = $path.time().".jpg";
if(watermark_text($path.$_FILES['imgfile']['name'], $new_name))
$demo_image = $new_name;

}
}

else
$msg="Максимальный размер файла 2МБ, поддерживаемые форматы .jpg and .bmp";
}
}

?>
<html>
<
head>
<
title>
Watemark
</title>

<
style type="text/css">
body{ width:800px; margin: 15px auto; padding:0px; font-family: arial}

</style>

</
head>
<
body>

<
form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" >
<
fieldset>
<
legend>Ваши данные</legend>
Ваше изображение :<input type="file" name="imgfile[]" id="imgfile"/> Ваш текст: <input style="margin-left: 69;" type="text" name="usertext" value="© "><br>
Цвет текста: <select style="margin-left: 54;" name="usertextcolor" size="1">
<
option value="white">Белый</option>
<
option value="black">Черный</option>
</
select></br>
<
input type="submit" name="createmark" id="createmark" value="Submit" />
</
fieldset>
<? echo $noimg; ?>
<?
PHP
if(!empty($demo_image))
echo '<br/><center><div style="max-width:800px;"><img style="max-width:790px;" src="'.$demo_image.'" /></div></center>';
else
echo '<h3>'.$msg.'</h3>';
?>
</form>


</
body>
</
html>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.