0
這裏是我用什麼來創建圖像縮小,但沒有得到解決如何使用php降低圖像質量/圖像大小,我們試過但無法解決?
該代碼同時將圖像從我選擇的道路,從計算機和上傳的是,像相同的圖像尺寸和相同的質量代碼,但我希望是相同的比率
減少圖像尺寸<?php
include '../database/db.php';
include "../includes/session.php";
if(isset($_GET["d"]))
{
$output_dir=($_GET['d']);
$directory=($_GET['fp']);
$pid=($_GET['pid']);
$lid=($_GET['lid']);
$subjecta=($_GET['subject']);
}
if(isset($_FILES["myfile"]))
{
$ret = array();
$error =$_FILES["myfile"]["error"];
//You need to handle both cases
//If Any browser does not support serializing of multiple files using FormData()
if(!is_array($_FILES["myfile"]["name"])) //single file
{
$fileName = $_FILES["myfile"]["name"];
move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir.$fileName);
$ret[]= $fileName;
$path = "$directory$fileName";
$query = "INSERT INTO table_name (lid,pid,nots,filename)VALUES('$lid','$pid','$path','$fileName')";
$suc= mysql_query($query);
}else{
$fileCount = count($_FILES["myfile"]["name"]);
for($i=0; $i < $fileCount; $i++)
{
$fileName = $_FILES["myfile"]["name"][$i];
move_uploaded_file($_FILES["myfile"]["tmp_name"][$i],$output_dir.$fileName);
$ret[]= $fileName;
$path = "$directory$fileName";
$query = "INSERT INTO table_name (lid,pid,nots,filename)VALUES('$lid','$pid','$path','$fileName')";
$suc= mysql_query($query);
}
}
echo json_encode($ret);
}
?>
我們做這個代碼的單個文件的多個文件
JSON無關與圖像尺寸或質量。 – Difster
圖像處理代碼在哪裏? –
'imagecopyresampled'似乎是最適合這個 – RamRaider