PHP 图像调整大小以获取名称和路径


PHP image resize getting name and path

我试图弄清楚它将新的调整大小的图像放在这里的位置。

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作为资源图像,但我不确定如何使用回显来找出它们的值。我正在尝试做的是找出它放置调整大小的图像的位置,以便我可以重命名它。

任何帮助都会很棒!

我假设这段代码驻留在一个类中。如 createFile 函数的第 9 行,文件可能驻留在以下路径:

echo $this->uploaddir. $imageNewName .'.'.$this->ext;