Model grid thumbnail are now jpeg by default.

- TODO: Automatically detect "PNG" files and request jpeg for thumbnails.
This commit is contained in:
Christian Bastian
2024-07-19 17:29:05 -04:00
parent 7be410dabc
commit 73f10c7da1
2 changed files with 63 additions and 16 deletions

View File

@@ -114,9 +114,11 @@ class SearchPath {
* @param {string | undefined} [dateImageModified=undefined]
* @param {string | undefined} [width=undefined]
* @param {string | undefined} [height=undefined]
* @param {string | undefined} [imageFormat=undefined]
* @param {string | undefined} [quality=undefined]
* @returns {string}
*/
function imageUri(imageSearchPath = undefined, dateImageModified = undefined, width = undefined, height = undefined) {
function imageUri(imageSearchPath = undefined, dateImageModified = undefined, width = undefined, height = undefined, imageFormat = undefined, quality = undefined) {
const path = imageSearchPath ?? "no-preview";
const date = dateImageModified;
let uri = `/model-manager/preview/get?uri=${path}`;
@@ -129,11 +131,19 @@ function imageUri(imageSearchPath = undefined, dateImageModified = undefined, wi
if (date !== undefined && date !== null) {
uri += `&v=${date}`;
}
if (imageFormat !== undefined && imageFormat !== null) {
uri += `&image-format=${imageFormat}`;
}
if (quality !== undefined && quality !== null) {
uri += `&quality=${quality}`;
}
return uri;
}
const PREVIEW_NONE_URI = imageUri();
const PREVIEW_THUMBNAIL_WIDTH = 320;
const PREVIEW_THUMBNAIL_HEIGHT = 480;
const PREVIEW_THUMBNAIL_FORMAT = "JPEG";
const PREVIEW_THUMBNAIL_QUALITY = undefined;
/**
* @param {(...args) => void} callback
@@ -1701,6 +1711,8 @@ class ModelGrid {
previewInfo?.dateModified,
PREVIEW_THUMBNAIL_WIDTH,
PREVIEW_THUMBNAIL_HEIGHT,
PREVIEW_THUMBNAIL_FORMAT,
PREVIEW_THUMBNAIL_QUALITY,
),
draggable: false,
}),