Skip to content

Commit 6bc44e8

Browse files
authored
Add pdf and jxl formats (#59)
* Add jxl and pdf to formats * changesets * Add them alto to skip_processing * Fix tests
1 parent 0ab711a commit 6bc44e8

File tree

7 files changed

+15
-2
lines changed

7 files changed

+15
-2
lines changed

.changeset/lovely-streets-write.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@imgproxy/imgproxy-js-core": patch
3+
---
4+
5+
Add pdf and jxl to [format](https://docs.imgproxy.net/usage/processing#format) option

src/options/format.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { guardIsUndef, guardIsValidVal } from "../utils";
44
const formatValues = {
55
png: true,
66
jpg: true,
7+
jxl: true,
78
webp: true,
89
avif: true,
910
gif: true,
@@ -12,6 +13,7 @@ const formatValues = {
1213
bmp: true,
1314
tiff: true,
1415
mp4: true,
16+
pdf: true,
1517
best: true,
1618
};
1719

src/options/skipProcessing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { guardIsUndef, guardIsNotArray } from "../utils";
66

77
const extNames = [
88
"jpg",
9+
"jxl",
910
"png",
1011
"webp",
1112
"avif",

src/types/format.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* At the moment, imgproxy supports only the most popular image formats.
66
* - `png` — Portable Network Graphics
77
* - `jpg` — Joint Photographic Experts Group
8+
* - `jxl` — JPEG XL
89
* - `webp` — WebP
910
* - `avif` — AV1 Image File Format
1011
* - `gif` — Graphics Interchange Format
@@ -13,6 +14,7 @@
1314
* - `bmp` — Bitmap
1415
* - `tiff` — Tagged Image File Format
1516
* - `mp4` — **PRO feature** MPEG-4
17+
* - `pdf` — **PRO feature** PDF document
1618
* - `best` — **PRO feature** to make imgproxy pick the best format for the
1719
* resultant image. Check out the {@link https://docs.imgproxy.net/best_format | Best format guide}
1820
* to learn more.
@@ -25,6 +27,7 @@
2527
type Format =
2628
| "png"
2729
| "jpg"
30+
| "jxl"
2831
| "webp"
2932
| "avif"
3033
| "gif"
@@ -33,6 +36,7 @@ type Format =
3336
| "bmp"
3437
| "tiff"
3538
| "mp4"
39+
| "pdf"
3640
| "best";
3741

3842
/**

src/types/skipProcessing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
type SkipProcessing = Array<
2525
| "jpg"
26+
| "jxl"
2627
| "png"
2728
| "webp"
2829
| "avif"

tests/optionsBasic/format.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("format", () => {
2828
it("should throw an error if format is invalid", () => {
2929
// @ts-expect-error: Let's ignore an error (check for users with vanilla js).
3030
expect(() => build({ format: "invalid" })).toThrow(
31-
"format option is invalid. Valid values are: png, jpg, webp, avif, gif, ico, svg, bmp, tiff, mp4, best"
31+
"format option is invalid. Valid values are: png, jpg, jxl, webp, avif, gif, ico, svg, bmp, tiff, mp4, pdf, best"
3232
);
3333
});
3434

tests/optionsBasic/skipProcessing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("skipProcessing", () => {
3737
it("should throw an error if skipProcessing contains unsupported extensions", () => {
3838
// @ts-expect-error: Let's ignore an error (check for users with vanilla js).
3939
expect(() => build({ skip_processing: ["tiff", "jpeg"] })).toThrow(
40-
"skip_processing option contains unsupported extension. Valid values are: jpg,png,webp,avif,gif,ico,svg,heic,bmp,tiff,pdf,mp4"
40+
"skip_processing option contains unsupported extension. Valid values are: jpg,jxl,png,webp,avif,gif,ico,svg,heic,bmp,tiff,pdf,mp4"
4141
);
4242
});
4343

0 commit comments

Comments
 (0)