我想保存的文件夾中不同類別的圖像,並檢索them..and當我保存的圖像保存,水印被自動應用使圖像.. 此我使用。圖像不是在載文件夾
<?php
if(isset($_POST['submit'])){
$cat=$_POST['cat'];
$fname= $_FILES["file"]["name"];
"Type: " . $_FILES["file"]["type"] . "<br />";
"Size: " . ($_FILES["file"]["size"]/1024) . " Kb<br />";
"stored in: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
"Stored in: " . "upload/" . $_FILES["file"]["name"];
echo 'image Save Successfully' ;
require_once("watermark.php");
$original_directory = "upload/";
$watermarked_images = "temp/";
if ($handle = opendir($original_directory))
{
while (false !== ($file = readdir($handle)))
{
if(!is_file($original_directory.$file))
continue;
if(exif_imagetype($original_directory.$file)==2)
{
watermark($original_directory.$file,"watermark.png",$watermarked_images.$file);
//echo "Done watermarking <b>".$file."</b><br>\n";
}
}
closedir($handle);
}
}
}
?>
和watermark.php是
<?php
function watermark($original_image,$original_watermark,$destination="")
{
$image=imagecreatefromjpeg($original_image);
list($imagewidth,$imageheight)=getimagesize($original_image);
$watermark = imagecreatefrompng($original_watermark);
list($watermarkwidth,$watermarkheight)=getimagesize($original_watermark);
if($watermarkwidth>$imagewidth || $watermarkheight>$imageheight)
{
$water_resize_factor = $imagewidth/$watermarkwidth;
$new_watermarkwidth = $watermarkwidth * $water_resize_factor;
$new_watermarkheight = $watermarkheight * $water_resize_factor;
$new_watermark = imagecreatetruecolor($new_watermarkwidth , $new_watermarkheight);
imagealphablending($new_watermark , false);
imagecopyresampled($new_watermark , $watermark, 0, 0, 0, 0, $new_watermarkwidth, $new_watermarkheight, $watermarkwidth, $watermarkheight);
$watermarkwidth = $new_watermarkwidth;
$watermarkheight = $new_watermarkheight;
$watermark = $new_watermark;
}
$startwidth = ($imagewidth - $watermarkwidth)/2;
$startheight = ($imageheight - $watermarkheight)/2;
imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight);
if(!empty($destination))
imagejpeg($image,$destination);
else
imagejpeg($image);
}
?>
一些圖像保存在文件夾上傳和臨時文件夾和數據庫也和水印是在them..but應用現在,當我試圖上傳圖片..its雲只有在上傳文件夾和一個致命錯誤顯示: -
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 15000 bytes) in D:\xampp\htdocs\looks\admin\watermark.php on line 28
我怎樣才能解決這個.. 和PNG圖片是不是也節省
變化在php.ini – KAsh 2013-02-28 12:05:54
文件上傳大小限制,你應該修改你的php.ini來解決這個 – 2013-02-28 12:05:57
可能dublicate http://stackoverflow.com/questions/415801/allowed-memory-size-of- 33554432字節枯竭,試圖對分配-43148176字節 – chriz 2013-02-28 12:07:16