getFilename() : $targetName; if (empty($targetName)) { throw ImageException::forInvalidFile($targetName); } if (! is_dir($targetPath)) { mkdir($targetName, 0755, true); } if (! copy($this->getPathname(), "{$targetPath}{$targetName}")) { throw ImageException::forCopyError($targetPath); } chmod("{$targetPath}/{$targetName}", $perms); return true; } //-------------------------------------------------------------------- /** * Get image properties * * A helper function that gets info about the file * * @param boolean $return * * @return mixed */ public function getProperties(bool $return = false) { $path = $this->getPathname(); $vals = getimagesize($path); $types = [ 1 => 'gif', 2 => 'jpeg', 3 => 'png', ]; $mime = 'image/' . ($types[$vals[2]] ?? 'jpg'); if ($return === true) { return [ 'width' => $vals[0], 'height' => $vals[1], 'image_type' => $vals[2], 'size_str' => $vals[3], 'mime_type' => $mime, ]; } $this->origWidth = $vals[0]; $this->origHeight = $vals[1]; $this->imageType = $vals[2]; $this->sizeStr = $vals[3]; $this->mime = $mime; return true; } //-------------------------------------------------------------------- }