File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @riffyh/server" ,
3- "version" : " 1.2.1 " ,
3+ "version" : " 1.2.2 " ,
44 "repository" : {
55 "type" : " git" ,
66 "url" : " git+https://github.com/rayriffy/rayriffy-h.git"
2929 "@toon-tools/elysia" : " 1.1.0" ,
3030 "debug" : " 4.4.3" ,
3131 "elysia" : " 1.4.29" ,
32- "sharp" : " 0.35.2" ,
3332 "tweetnacl" : " 1.0.3" ,
3433 "tweetnacl-util" : " 0.15.1"
3534 },
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import { cors } from "@elysiajs/cors";
66import { toon } from "@toon-tools/elysia" ;
77
88import { defineCacheInstance } from "@rayriffy/filesystem" ;
9- import sharp from "sharp" ;
109import { galleryModel , listingResultModel , type Config } from "@riffyh/commons" ;
1110import debug from "debug" ;
1211import path from "node:path" ;
@@ -166,17 +165,23 @@ const server = new Elysia()
166165 const dataSource = config . dataSources . find ( ( o ) => o . key === query . dataSource ) ;
167166 if ( dataSource === undefined ) throw new Error ( `data source ${ query . dataSource } not found` ) ;
168167
169- const fetchedImage = await dataSource . getImage ( {
170- url : query . url ,
171- } ) ;
172- const resizedImage = await sharp ( fetchedImage )
173- . resize ( {
174- width : query . type === "cover" ? 640 : 1280 ,
175- } )
176- . toFormat ( query . format , {
168+ const fetchedImage = new Bun . Image (
169+ await dataSource . getImage ( {
170+ url : query . url ,
171+ } ) ,
172+ ) . resize ( query . type === "cover" ? 640 : 1280 ) ;
173+
174+ // if query.format is webp, then convert to webp
175+ if ( query . format === "webp" )
176+ fetchedImage . webp ( {
177177 quality : 72 ,
178- } )
179- . toBuffer ( ) ;
178+ } ) ;
179+ else if ( query . format === "jpeg" )
180+ fetchedImage . jpeg ( {
181+ quality : 72 ,
182+ } ) ;
183+
184+ const resizedImage = await fetchedImage . buffer ( ) ;
180185 await cache . write (
181186 cacheKeys ,
182187 resizedImage ,
You can’t perform that action at this time.
0 commit comments