增强预览机制
This commit is contained in:
@@ -179,7 +179,15 @@ Future<Response> _getPhotoPreviewHandler(Request req) async {
|
||||
return Response.notFound('Photo not found');
|
||||
}
|
||||
|
||||
final file = await vips.generatePreview(photo.filePath);
|
||||
// 从查询参数获取宽度和高度
|
||||
final w = int.tryParse(req.url.queryParameters['w'] ?? '');
|
||||
final h = int.tryParse(req.url.queryParameters['h'] ?? '');
|
||||
|
||||
final file = await vips.generatePreview(
|
||||
photo.filePath,
|
||||
w: w,
|
||||
h: h,
|
||||
);
|
||||
|
||||
if (!await file.exists()) {
|
||||
return Response.notFound('File not found');
|
||||
@@ -206,7 +214,7 @@ Future<Response> _getPhotoPreviewHandler(Request req) async {
|
||||
return Response.ok(
|
||||
streamController.stream,
|
||||
headers: {
|
||||
'Content-Type': photo.mimeType,
|
||||
'Content-Type': 'image/webp',
|
||||
'Content-Length': file.statSync().size.toString(),
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user