diff --git a/.changeset/lovely-streets-write.md b/.changeset/lovely-streets-write.md new file mode 100644 index 00000000..82b611e6 --- /dev/null +++ b/.changeset/lovely-streets-write.md @@ -0,0 +1,5 @@ +--- +"@imgproxy/imgproxy-js-core": patch +--- + +Add pdf and jxl to [format](https://docs.imgproxy.net/usage/processing#format) option diff --git a/src/options/format.ts b/src/options/format.ts index b2bdaa3a..b6d7f7a8 100644 --- a/src/options/format.ts +++ b/src/options/format.ts @@ -4,6 +4,7 @@ import { guardIsUndef, guardIsValidVal } from "../utils"; const formatValues = { png: true, jpg: true, + jxl: true, webp: true, avif: true, gif: true, @@ -12,6 +13,7 @@ const formatValues = { bmp: true, tiff: true, mp4: true, + pdf: true, best: true, }; diff --git a/src/options/skipProcessing.ts b/src/options/skipProcessing.ts index 4e4e85bf..6ba122e4 100644 --- a/src/options/skipProcessing.ts +++ b/src/options/skipProcessing.ts @@ -6,6 +6,7 @@ import { guardIsUndef, guardIsNotArray } from "../utils"; const extNames = [ "jpg", + "jxl", "png", "webp", "avif", diff --git a/src/types/format.ts b/src/types/format.ts index eae61851..f2cb7875 100644 --- a/src/types/format.ts +++ b/src/types/format.ts @@ -5,6 +5,7 @@ * At the moment, imgproxy supports only the most popular image formats. * - `png` — Portable Network Graphics * - `jpg` — Joint Photographic Experts Group + * - `jxl` — JPEG XL * - `webp` — WebP * - `avif` — AV1 Image File Format * - `gif` — Graphics Interchange Format @@ -13,6 +14,7 @@ * - `bmp` — Bitmap * - `tiff` — Tagged Image File Format * - `mp4` — **PRO feature** MPEG-4 + * - `pdf` — **PRO feature** PDF document * - `best` — **PRO feature** to make imgproxy pick the best format for the * resultant image. Check out the {@link https://docs.imgproxy.net/best_format | Best format guide} * to learn more. @@ -25,6 +27,7 @@ type Format = | "png" | "jpg" + | "jxl" | "webp" | "avif" | "gif" @@ -33,6 +36,7 @@ type Format = | "bmp" | "tiff" | "mp4" + | "pdf" | "best"; /** diff --git a/src/types/skipProcessing.ts b/src/types/skipProcessing.ts index 6bac1b4d..a1e78eb5 100644 --- a/src/types/skipProcessing.ts +++ b/src/types/skipProcessing.ts @@ -23,6 +23,7 @@ */ type SkipProcessing = Array< | "jpg" + | "jxl" | "png" | "webp" | "avif" diff --git a/tests/optionsBasic/format.test.ts b/tests/optionsBasic/format.test.ts index c833fc53..9c0be0ee 100644 --- a/tests/optionsBasic/format.test.ts +++ b/tests/optionsBasic/format.test.ts @@ -28,7 +28,7 @@ describe("format", () => { it("should throw an error if format is invalid", () => { // @ts-expect-error: Let's ignore an error (check for users with vanilla js). expect(() => build({ format: "invalid" })).toThrow( - "format option is invalid. Valid values are: png, jpg, webp, avif, gif, ico, svg, bmp, tiff, mp4, best" + "format option is invalid. Valid values are: png, jpg, jxl, webp, avif, gif, ico, svg, bmp, tiff, mp4, pdf, best" ); }); diff --git a/tests/optionsBasic/skipProcessing.test.ts b/tests/optionsBasic/skipProcessing.test.ts index 25488c9c..e61684cb 100644 --- a/tests/optionsBasic/skipProcessing.test.ts +++ b/tests/optionsBasic/skipProcessing.test.ts @@ -37,7 +37,7 @@ describe("skipProcessing", () => { it("should throw an error if skipProcessing contains unsupported extensions", () => { // @ts-expect-error: Let's ignore an error (check for users with vanilla js). expect(() => build({ skip_processing: ["tiff", "jpeg"] })).toThrow( - "skip_processing option contains unsupported extension. Valid values are: jpg,png,webp,avif,gif,ico,svg,heic,bmp,tiff,pdf,mp4" + "skip_processing option contains unsupported extension. Valid values are: jpg,jxl,png,webp,avif,gif,ico,svg,heic,bmp,tiff,pdf,mp4" ); });