我想弄清楚它把新的調整大小的圖像在這裏。PHP的圖像調整大小獲取名稱和路徑
function createFile($output_filename = null,$imageNewName) {
if($this->ext == "JPG" OR $this->ext == "JPEG") {
imageJPEG($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext, $this->quality);
} elseif($this->ext == "PNG") {
imagePNG($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext);
} elseif($this->ext == "GIF") {
imageGIF($this->dst_r, $this->uploaddir.$imageNewName.'.'.$this->ext);
}
$this->output = $this->uploaddir. $imageNewName;
echo $this->uploaddir. $imageNewName .'.'.$this->ext;
}
function resize($newWidth, $newHeight) {
$width = imagesx($this->img_r);
$height = imagesy($this->img_r);
$newWidth = $newWidth;
$newHeight = $newHeight;
$this->dst_r = ImageCreateTrueColor($newWidth, $newHeight);
imagecopyresampled($this->dst_r, $this->img_r, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
$this->img_r = $this->dst_r;
$this->img_h = $newHeight;
$this->img_w = $newWidth;
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/img/nonfb/';
$fileNameBase = $_FILES['Filedata']['name'];
$extension = pathinfo($fileNameBase, PATHINFO_EXTENSION);
$fileNameNEW = $imageNewName . '.' . $extension;
$targetFile = str_replace('//','/',$targetPath) . $fileNameNEW;
echo 'TARGET=' . $targetFile;
move_uploaded_file ($tempFile, $targetFile);
$image = new Image();
$image->setFile($targetFile);
$image->setUploadDir($targetPath);
$image->resize(50,50);
$image->createFile(md5($tempFile,$fileNameNEW));
$image->flush()
我可以告訴它走的是dst_r作爲當前圖像和IMG_R作爲資源圖像但林不知道如何使用呼應這些,找出它們的值。我想要做的是找出它的位置,調整大小的圖像,所以我可以重命名它。
任何幫助將是偉大的!
dst_r/IMG_R的價值觀是無用的。它們只是GD資源句柄,並且在當前正在執行的腳本的上下文之外沒有意義。 –
$ _REQUEST ['folder']看起來不太安全 – Scuzzy