-
Notifications
You must be signed in to change notification settings - Fork 293
/
Copy pathbunny.ts
37 lines (34 loc) · 879 Bytes
/
bunny.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { joinURL } from 'ufo'
import { defineProvider, createOperationsGenerator } from '#image'
const operationsGenerator = createOperationsGenerator({
keyMap: {
width: 'width',
height: 'height',
aspectRatio: 'aspect_ratio',
quality: 'quality',
sharpen: 'sharpen',
blur: 'blur',
crop: 'crop',
cropGravity: 'crop_gravity',
flip: 'flip',
flop: 'flop',
brightness: 'brightness',
saturation: 'saturation',
hue: 'hue',
contrast: 'contrast',
autoOptimize: 'auto_optimize',
sepia: 'sepia',
},
})
interface BunnyOptions {
baseURL: string
// TODO: more modifiers
}
export default defineProvider<BunnyOptions>({
getImage: (src, { modifiers, baseURL }) => {
const operations = operationsGenerator(modifiers)
return {
url: joinURL(baseURL, src + (operations ? '?' + operations : '')),
}
},
})