fix: watermark svg xlink, object-contain for vertical images, remove duplicate search form
This commit is contained in:
1 parent
986828893b
commit
7e85b35486
5 files changed
+20
-24
No files matched your search
@@ -53,7 +53,7 @@ function AlbumCard({ album, editorialId, grantAction, revokeAction, notifyAction
|
|||||||
<div className="relative aspect-[3/2] bg-gray-100 overflow-hidden">
|
<div className="relative aspect-[3/2] bg-gray-100 overflow-hidden">
|
||||||
{album.albumThumbnailAssetId ? (
|
{album.albumThumbnailAssetId ? (
|
||||||
<Image
|
<Image
|
||||||
className="w-full h-full object-cover transition-transform duration-500 hover:scale-105"
|
className="w-full h-full object-contain transition-transform duration-500 hover:scale-105"
|
||||||
alt={`Titelbild von ${album.albumName}`}
|
alt={`Titelbild von ${album.albumName}`}
|
||||||
height={200}
|
height={200}
|
||||||
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
|
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
|
||||||
|
|||||||
@@ -118,31 +118,35 @@ async function watermarkedThumbnailResponse(thumbnail: ImmichBinary, assetId: st
|
|||||||
const targetWidth = 480;
|
const targetWidth = 480;
|
||||||
const resizedBuffer = await sharp(buffer)
|
const resizedBuffer = await sharp(buffer)
|
||||||
.resize({ width: targetWidth, withoutEnlargement: true })
|
.resize({ width: targetWidth, withoutEnlargement: true })
|
||||||
.toBuffer();
|
let watermarked = buffer;
|
||||||
|
|
||||||
const resizedMetadata = await sharp(resizedBuffer).metadata();
|
|
||||||
const width = resizedMetadata.width ?? targetWidth;
|
|
||||||
const height = resizedMetadata.height ?? 300;
|
|
||||||
|
|
||||||
let watermarked = resizedBuffer;
|
|
||||||
try {
|
try {
|
||||||
const logoPath = path.join(process.cwd(), "public", "brand", "logo-white.png");
|
const logoPath = path.join(process.cwd(), "public", "brand", "logo-white.png");
|
||||||
const logoBuffer = await fs.readFile(logoPath);
|
const logoBuffer = await fs.readFile(logoPath);
|
||||||
|
|
||||||
// Logo auf 60% der Bildbreite skalieren
|
// Skaliere das Bild so, dass es in eine 800x800 Box passt (damit Hoch- und Querformat korrekt skaliert werden)
|
||||||
const logoTargetWidth = Math.round(width * 0.6);
|
const targetSize = 800;
|
||||||
|
const resizedBuffer = await sharp(buffer)
|
||||||
|
.resize({ width: targetSize, height: targetSize, fit: "inside", withoutEnlargement: true })
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { width, height } = await sharp(resizedBuffer).metadata();
|
||||||
|
|
||||||
|
// Berechne Wasserzeichen-Größe (50% der Bildbreite, max 400px)
|
||||||
|
const logoTargetWidth = Math.min(Math.floor((width ?? targetSize) * 0.5), 400);
|
||||||
|
|
||||||
const resizedLogo = await sharp(logoBuffer)
|
const resizedLogo = await sharp(logoBuffer)
|
||||||
.resize({ width: logoTargetWidth, withoutEnlargement: true })
|
.resize({ width: logoTargetWidth, withoutEnlargement: true })
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
const logoBase64 = resizedLogo.toString("base64");
|
|
||||||
const logoMetadata = await sharp(resizedLogo).metadata();
|
const logoMetadata = await sharp(resizedLogo).metadata();
|
||||||
|
const logoBase64 = resizedLogo.toString("base64");
|
||||||
const logoWidth = logoMetadata.width ?? logoTargetWidth;
|
const logoWidth = logoMetadata.width ?? logoTargetWidth;
|
||||||
const logoHeight = logoMetadata.height ?? (logoTargetWidth / 2);
|
const logoHeight = logoMetadata.height ?? (logoTargetWidth / 2);
|
||||||
|
|
||||||
|
// XLink wird für librsvg (welches von sharp genutzt wird) zwingend benötigt
|
||||||
const svgOverlay = `
|
const svgOverlay = `
|
||||||
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<image href="data:image/png;base64,${logoBase64}" x="${(width - logoWidth) / 2}" y="${(height - logoHeight) / 2}" width="${logoWidth}" height="${logoHeight}" opacity="0.6"/>
|
<image xlink:href="data:image/png;base64,${logoBase64}" x="${((width ?? targetSize) - logoWidth) / 2}" y="${((height ?? targetSize) - logoHeight) / 2}" width="${logoWidth}" height="${logoHeight}" opacity="0.6"/>
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -610,7 +610,7 @@ a {
|
|||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
aspect-ratio: 3 / 2;
|
aspect-ratio: 3 / 2;
|
||||||
object-fit: cover;
|
object-fit: contain;
|
||||||
background: var(--contact-sheet);
|
background: var(--contact-sheet);
|
||||||
transition: transform 150ms ease-out;
|
transition: transform 150ms ease-out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default async function LightboxPage() {
|
|||||||
<div className="aspect-[3/2] w-full overflow-hidden bg-muted">
|
<div className="aspect-[3/2] w-full overflow-hidden bg-muted">
|
||||||
<Image
|
<Image
|
||||||
alt={asset.originalFileName ?? "Bild"}
|
alt={asset.originalFileName ?? "Bild"}
|
||||||
className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
|
className="w-full h-full object-contain transition-transform duration-300 group-hover:scale-105"
|
||||||
height={200}
|
height={200}
|
||||||
src={`/api/assets/${encodeURIComponent(item.assetId)}/thumbnail`}
|
src={`/api/assets/${encodeURIComponent(item.assetId)}/thumbnail`}
|
||||||
width={300}
|
width={300}
|
||||||
|
|||||||
@@ -62,14 +62,6 @@ export function PhotoContactSheet({
|
|||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<form action={albumId ? `/redaktion/alben/${encodeURIComponent(albumId)}` : '/redaktion/alben'} aria-label={`Fotos in ${albumName} durchsuchen`} className="photo-search" role="search">
|
|
||||||
<label htmlFor="photo-query">Suchbegriff</label>
|
|
||||||
<div className="photo-search-controls">
|
|
||||||
<input defaultValue={query} id="photo-query" name="suche" type="search" />
|
|
||||||
<button type="submit">Fotos suchen</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<p aria-live="polite" className="result-summary" role="status">
|
<p aria-live="polite" className="result-summary" role="status">
|
||||||
{formatCount(page.total, "Foto")} gefunden
|
{formatCount(page.total, "Foto")} gefunden
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in new issue
Block a user