Schema: Bildoperationen (removeBackground/dropShadow/flatten) und Asset-Bildmodus

- image-filter.schema.json: removeBackground (color/tolerance/fromEdges/edgeBlur/
  referenceWidth), dropShadow (color/opacity/blur/offsets/padding/referenceWidth/
  canvas/background), flatten; Tippfehler mitchellNetravili -> mitchellNetravali
- asset.schema.json: optionaler imageProcessing-Block (access/cachePath/
  allowOriginal/defaultFilter/allowedInputTypes/limits/imageFilter)
- index.d.ts: passende Interfaces inkl. AssetConfig
- Beispiel: examples/server/asset-image-processing.yml, demo-api imageFilter.shadow
- validate-schemas.mjs: examples/server-Pattern je Schema
This commit is contained in:
apairon committed 2026-10-27 18:04:55 +00:00
1 parent f26f8c7802
commit 913d5f4cb6
6 files changed
+263 -4

No files matched your search

+22
View File
@@ -128,3 +128,25 @@ fields:
maxItems: 3
maxFileSize: "5MB"
accept: ["application/pdf"]
imageFilter:
shadow:
- width: 800
outputType: png
removeBackground:
color: "#FFFFFF"
tolerance: 8
fromEdges: true
edgeBlur: 1.5
referenceWidth: 1000
dropShadow:
color: "#000000"
opacity: 0.25
blur: 15
offsetX: 8
offsetY: 8
padding: 20
referenceWidth: 1000
canvas: expand
background: transparent
flatten: "#FFFFFF"
@@ -0,0 +1,36 @@
# Beispiel für einen Asset-Eintrag mit Bildverarbeitung (imageProcessing)
# (tibi-server, ProjectConfig.assets[]) — validiert gegen schemas/config/asset.schema.json.
# Hinweis: cachePath muss ein existierendes Verzeichnis ausserhalb des Quellpfads
# sein; die Ajv-Validierung prueft nur Form und Wertebereiche, keine Dateisystempfade.
name: product-images
path: ./media/products
imageProcessing:
access: public
cachePath: ./media-cache/products
allowOriginal: false
defaultFilter: shadow
allowedInputTypes: ["image/jpeg", "image/png", "image/webp"]
limits:
maxInputBytes: 26214400
maxPixels: 20000000
imageFilter:
shadow:
- width: 800
outputType: png
removeBackground:
color: "#FFFFFF"
tolerance: 8
fromEdges: true
edgeBlur: 1.5
referenceWidth: 1000
dropShadow:
color: "#000000"
opacity: 0.25
blur: 15
offsetX: 8
offsetY: 8
padding: 20
referenceWidth: 1000
canvas: expand
background: transparent
flatten: "#FFFFFF"
Vendored
+49 -2
View File
@@ -343,6 +343,26 @@ declare global {
export type PreviewConfig = string | EvalHtmlConfig | PreviewSlots
/** Image filter parameters — used in both CollectionConfig.imageFilter and ImagePackage.filter() */
export interface RemoveBackgroundParams {
color?: string
tolerance?: number
fromEdges?: boolean
edgeBlur?: number
referenceWidth?: number
}
export interface DropShadowParams {
color?: string
opacity?: number
blur?: number
offsetX?: number
offsetY?: number
padding?: number
referenceWidth?: number
canvas?: "expand" | "fixed"
background?: string
}
export interface ImageFilterParams {
width?: number
height?: number
@@ -355,7 +375,7 @@ declare global {
| "catmullRom"
| "lanczos"
| "box"
| "mitchellNetravili"
| "mitchellNetravali"
| "bSpline"
| "gaussian"
| "bartlett"
@@ -387,6 +407,33 @@ declare global {
skipLargerDimension?: boolean
skipLargerFilesize?: boolean
outputType?: "jpg" | "jpeg" | "png" | "webp"
removeBackground?: RemoveBackgroundParams
dropShadow?: DropShadowParams
flatten?: string
}
/** Limits for asset image processing (`imageProcessing.limits`) */
export interface AssetImageLimitsConfig {
maxInputBytes?: number
maxPixels?: number
}
/** Asset image processing block (`imageProcessing`) */
export interface AssetImageProcessingConfig {
access: "public"
cachePath: string
allowOriginal?: boolean
defaultFilter?: string
allowedInputTypes?: Array<"image/jpeg" | "image/png" | "image/webp">
limits?: AssetImageLimitsConfig
imageFilter: { [name: string]: ImageFilterParams[] } | string
}
/** Asset config entry */
export interface AssetConfig {
name: string
path: string
imageProcessing?: AssetImageProcessingConfig
}
/** Collection config as returned by context.collection() – JSON-serialized from Go CollectionConfig */
@@ -573,7 +620,7 @@ declare global {
lastReload: string
namespace: string
meta?: { [key: string]: any }
assets?: { name: string; path: string }[]
assets?: AssetConfig[]
collections?: CollectionInfo[]
actions?: ActionInfo[]
jobs?: JobConfig[]
+63
View File
@@ -13,6 +13,69 @@
},
"path": {
"type": "string"
},
"imageProcessing": {
"type": "object",
"additionalProperties": false,
"properties": {
"access": {
"type": "string",
"enum": [
"public"
]
},
"cachePath": {
"type": "string"
},
"allowOriginal": {
"type": "boolean"
},
"defaultFilter": {
"type": "string"
},
"allowedInputTypes": {
"type": "array",
"items": {
"type": "string",
"enum": [
"image/jpeg",
"image/png",
"image/webp"
]
}
},
"limits": {
"type": "object",
"additionalProperties": false,
"properties": {
"maxInputBytes": {
"type": "integer",
"minimum": 1,
"maximum": 67108864
},
"maxPixels": {
"type": "integer",
"minimum": 1,
"maximum": 40000000
}
}
},
"imageFilter": {
"oneOf": [
{
"type": "string"
},
{
"$ref": "image-filter.schema.json"
}
]
}
},
"required": [
"access",
"cachePath",
"imageFilter"
]
}
},
"required": [
+91 -1
View File
@@ -33,7 +33,7 @@
"catmullRom",
"lanczos",
"box",
"mitchellNetravili",
"mitchellNetravali",
"bSpline",
"gaussian",
"bartlett",
@@ -102,6 +102,96 @@
"png",
"webp"
]
},
"removeBackground": {
"type": "object",
"additionalProperties": false,
"properties": {
"color": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"tolerance": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"fromEdges": {
"type": "boolean"
},
"edgeBlur": {
"type": "number",
"minimum": 0,
"maximum": 1000
},
"referenceWidth": {
"type": "integer",
"minimum": 0,
"maximum": 100000
}
}
},
"dropShadow": {
"type": "object",
"additionalProperties": false,
"properties": {
"color": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
"opacity": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"blur": {
"type": "number",
"minimum": 0,
"maximum": 1000
},
"offsetX": {
"type": "number",
"minimum": -1000,
"maximum": 1000
},
"offsetY": {
"type": "number",
"minimum": -1000,
"maximum": 1000
},
"padding": {
"type": "number",
"minimum": 0,
"maximum": 10000
},
"referenceWidth": {
"type": "integer",
"minimum": 0,
"maximum": 100000
},
"canvas": {
"type": "string",
"enum": [
"expand",
"fixed"
]
},
"background": {
"oneOf": [
{
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
},
{
"const": "transparent"
}
]
}
}
},
"flatten": {
"type": "string",
"pattern": "^#[0-9a-fA-F]{6}$"
}
}
}
+2 -1
View File
@@ -66,7 +66,8 @@ const validations = [
{ schema: "asset.schema.json", pattern: "demo-api/assets/*.y*ml" },
// Server-level Abschnitt (config.yml des tibi-servers), Beispiel getrennt
// vom Projekt-Demo unter examples/server/:
{ schema: "embedding.schema.json", pattern: "examples/server/*.y*ml" },
{ schema: "embedding.schema.json", pattern: "examples/server/embedding*.y*ml" },
{ schema: "asset.schema.json", pattern: "examples/server/asset-*.y*ml" },
]
let hasErrors = false