mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
feat(config): ✨ Add option to never convert vector images
This commit is contained in:
parent
6ef3a854d9
commit
de9dca5735
|
|
@ -160,6 +160,8 @@ convert_images = true
|
|||
# Can be: "image/jxl", "image/webp", "image/avif", "image/png", "image/jpeg", "image/heif", "image/gif"
|
||||
# JXL support will likely not work
|
||||
convert_to = "image/webp"
|
||||
# Also convert SVG images?
|
||||
convert_vector = false
|
||||
|
||||
# [s3]
|
||||
# Can be left blank if you don't use the S3 media backend
|
||||
|
|
|
|||
|
|
@ -224,10 +224,12 @@ export const configValidator = z.object({
|
|||
.object({
|
||||
convert_images: z.boolean().default(false),
|
||||
convert_to: z.string().default("image/webp"),
|
||||
convert_vector: z.boolean().default(false),
|
||||
})
|
||||
.default({
|
||||
convert_images: false,
|
||||
convert_to: "image/webp",
|
||||
convert_vector: false,
|
||||
}),
|
||||
})
|
||||
.default({
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* @module MediaManager
|
||||
* @description Handles media conversion between formats
|
||||
*/
|
||||
import { config } from "config-manager";
|
||||
import sharp from "sharp";
|
||||
|
||||
export const supportedMediaFormats = [
|
||||
|
|
@ -33,6 +34,13 @@ export class MediaConverter {
|
|||
* @returns Whether the media is convertable
|
||||
*/
|
||||
public isConvertable(file: File) {
|
||||
if (
|
||||
file.type === "image/svg+xml" &&
|
||||
!config.media.conversion.convert_vector
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return supportedMediaFormats.includes(file.type);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue