Compare commits
2
Commits
e2cf30a307
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
519611d06b | ||
|
|
a0580ad085 |
No files matched your search
@@ -48,6 +48,7 @@ class Resizer
|
||||
private function createVariant(Image $original, ResizeParams $params): string
|
||||
{
|
||||
$quality = $params->quality ?: -1;
|
||||
$this->logger->info("Resizing image", ['params'=>$params]);
|
||||
|
||||
$original->toWidth($params->width ?? intval($_ENV["DEFAULT_WIDTH"]));
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ class SqliteImageDb implements ImageDb {
|
||||
quality INTEGER NULLABLE,
|
||||
content TEXT NOT NULL
|
||||
)');
|
||||
|
||||
// Create a unique index on the path and params
|
||||
$this->db->exec('CREATE UNIQUE INDEX IF NOT EXISTS images_path_width_height_quality ON images (path, width, height, quality)');
|
||||
}
|
||||
|
||||
public function findImage(string $path, ResizeParams $params): Image | null {
|
||||
@@ -33,10 +36,15 @@ class SqliteImageDb implements ImageDb {
|
||||
$query .= $params->quality ? ' AND quality = :quality' : ' AND quality IS NULL';
|
||||
|
||||
$stmt = $this->db->prepare($query);
|
||||
$stmt->bindParam(':path', $path);
|
||||
if ($params->width !== null) $stmt->bindParam(':width', $params->width);
|
||||
if ($params->height !== null) $stmt->bindParam(':height', $params->height);
|
||||
if ($params->quality !== null) $stmt->bindParam(':quality', $params->quality);
|
||||
|
||||
$queryParams = [
|
||||
':path' => $path,
|
||||
];
|
||||
if ($params->width !== null) $queryParams[':width'] = $params->width;
|
||||
if ($params->height !== null) $queryParams[':height'] = $params->height;
|
||||
if ($params->quality !== null) $queryParams[':quality'] = $params->quality;
|
||||
|
||||
$stmt->execute($queryParams);
|
||||
|
||||
$this->logger->info("Querying images", ['query' => $stmt->queryString]);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class ResizeParams
|
||||
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->width = intval($params['width']) ?: intval($_ENV["DEFAULT_WIDTH"]);
|
||||
$this->width = isset($params['width']) ? intval($params['width']) : intval($_ENV["DEFAULT_WIDTH"]);
|
||||
$this->height = intval($params['height']) ?: null;
|
||||
$this->quality = isset($params['quality']) ? intval($params['quality']) : null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user