Provider documentation
ImageEngine
Generate ImageEngine delivery directives under the imgeng query.
Setup
Install the framework package and the core package for the provider import:
npm install @desource/image @desource/image-svelte Save this as image.config.ts beside your example component. Replace sample domains and identifiers with
your own.
import type { ImageConfig } from '@desource/image';
import { imageEngineProvider } from '@desource/image/providers/imageengine';
export const imageConfig = {
provider: 'imageengine',
providers: {
imageengine: imageEngineProvider({
"baseURL": "https://your-engine.imgeng.in"
})
}
} satisfies ImageConfig; Registering this provider makes it the default for the configured components. To mix services, register each
provider and set provider="imageengine" on the image that should use this one.
Image source
Use a path resolved by the configured ImageEngine source.
/photo.jpgUsage
The example uses the shared configuration above and the Svelte image component.
<script lang="ts">
import { Image, setImageConfig } from '@desource/image-svelte';
import { imageConfig } from './image.config';
setImageConfig(imageConfig);
</script>
<Image
src="/photo.jpg"
alt="Sample image" width={800} height={500}
modifiers={{
"quality": 80,
"format": "webp",
"fit": "cover"
}}
/>Provider options
Pass shared defaults such as screens, domains, aliases and presets to the image configuration. Pass provider-specific defaults as modifiers in the provider factory.
Modifiers
Supports width, height, quality, format, fit, passThrough, sharpen, rotate, screenPercent, crop, metadata and maxDpr. Quality is converted to compression as 100 minus quality, capped at 99.
Set dimensions on the component and pass service-specific operations through modifiers, as shown
above. See the provider source for exact mappings and the service documentation for accepted values.
Provider notes
- Fit maps cover to cropbox, contain to letterbox, fill to stretch, and inside/outside to box. JPEG maps to jpg.
- The engine must be configured with access to the source image origin.