@@ -66,6 +66,10 @@ func BenchmarkImageMagickProcessor_Optimise_Avif(b *testing.B) {
6666 benchmarkWithFormats (b , []string {"image/avif" })
6767}
6868
69+ func BenchmarkImageMagickProcessor_Optimise_Jxl (b * testing.B ) {
70+ benchmarkWithFormats (b , []string {"image/jxl" })
71+ }
72+
6973func benchmarkWithFormats (b * testing.B , formats []string ) {
7074 f := fmt .Sprintf ("%s/%s" , "./test_files/transformations" , "medium-jpeg.jpg" )
7175
@@ -319,6 +323,29 @@ func TestImageMagickProcessor_Optimise_Avif(t *testing.T) {
319323 })
320324}
321325
326+ func TestImageMagickProcessor_Optimise_Jxl (t * testing.T ) {
327+ testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
328+ return proc .Optimise (& img.TransformationConfig {
329+ Src : & img.Image {
330+ Id : imgId ,
331+ Data : orig ,
332+ },
333+ SupportedFormats : []string {"image/jxl" },
334+ })
335+ },
336+ []* testTransformation {
337+ {"big-jpeg.jpg" , "" },
338+ {"medium-jpeg.jpg" , "image/jxl" },
339+ {"opaque-png.png" , "image/jxl" },
340+ {"animated.gif" , "" },
341+ {"animated-coalesce.gif" , "" },
342+ {"transparent-png.png" , "image/jxl" },
343+ {"small-transparent-png.png" , "image/jxl" },
344+ {"transparent-png-use-original.png" , "image/jxl" },
345+ {"logo.png" , "image/jxl" },
346+ })
347+ }
348+
322349func TestImageMagickProcessor_Optimise_Avif_Webp (t * testing.T ) {
323350 qualities := []img.Quality {img .DEFAULT , img .LOW , img .LOWER }
324351
@@ -349,6 +376,66 @@ func TestImageMagickProcessor_Optimise_Avif_Webp(t *testing.T) {
349376 }
350377}
351378
379+ func TestImageMagickProcessor_Optimise_Jxl_Avif_Webp (t * testing.T ) {
380+ qualities := []img.Quality {img .DEFAULT , img .LOW , img .LOWER }
381+
382+ for _ , q := range qualities {
383+ t .Run (fmt .Sprintf ("Quality_%d" , q ), func (t * testing.T ) {
384+ testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
385+ return proc .Optimise (& img.TransformationConfig {
386+ Src : & img.Image {
387+ Id : imgId ,
388+ Data : orig ,
389+ },
390+ Quality : q ,
391+ SupportedFormats : []string {"image/jxl" , "image/avif" , "image/webp" },
392+ })
393+ },
394+ []* testTransformation {
395+ {"big-jpeg.jpg" , "image/webp" },
396+ {"medium-jpeg.jpg" , "image/avif" },
397+ {"opaque-png.png" , "image/avif" },
398+ {"animated.gif" , "image/webp" },
399+ {"animated-coalesce.gif" , "image/webp" },
400+ {"transparent-png.png" , "image/avif" },
401+ {"small-transparent-png.png" , "image/jxl" },
402+ {"transparent-png-use-original.png" , "image/jxl" },
403+ {"logo.png" , "image/jxl" },
404+ })
405+ })
406+ }
407+ }
408+
409+ func TestImageMagickProcessor_Optimise_Jxl_Webp (t * testing.T ) {
410+ qualities := []img.Quality {img .DEFAULT , img .LOW , img .LOWER }
411+
412+ for _ , q := range qualities {
413+ t .Run (fmt .Sprintf ("Quality_%d" , q ), func (t * testing.T ) {
414+ testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
415+ return proc .Optimise (& img.TransformationConfig {
416+ Src : & img.Image {
417+ Id : imgId ,
418+ Data : orig ,
419+ },
420+ Quality : q ,
421+ SupportedFormats : []string {"image/jxl" , "image/webp" },
422+ })
423+ },
424+ []* testTransformation {
425+ {"big-jpeg.jpg" , "image/webp" },
426+ {"medium-jpeg.jpg" , "image/jxl" },
427+ {"opaque-png.png" , "image/jxl" },
428+ {"animated.gif" , "image/webp" },
429+ {"animated-coalesce.gif" , "image/webp" },
430+ {"transparent-png.png" , "image/jxl" },
431+ {"small-transparent-png.png" , "image/jxl" },
432+ {"transparent-png-use-original.png" , "image/jxl" },
433+ {"logo.png" , "image/jxl" },
434+ })
435+ })
436+ }
437+ }
438+
352439func TestImageMagickProcessor_Resize_Avif (t * testing.T ) {
353440 testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
354441 return proc .Resize (& img.TransformationConfig {
@@ -371,25 +458,46 @@ func TestImageMagickProcessor_Resize_Avif(t *testing.T) {
371458 })
372459}
373460
374- func TestImageMagickProcessor_FitToSize_Avif (t * testing.T ) {
461+ func TestImageMagickProcessor_Resize_Jxl (t * testing.T ) {
462+ testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
463+ return proc .Resize (& img.TransformationConfig {
464+ Src : & img.Image {
465+ Id : imgId ,
466+ Data : orig ,
467+ },
468+ SupportedFormats : []string {"image/jxl" },
469+ Config : & img.ResizeConfig {Size : "50" },
470+ })
471+ },
472+ []* testTransformation {
473+ {"big-jpeg.jpg" , "image/jxl" },
474+ {"medium-jpeg.jpg" , "image/jxl" },
475+ {"opaque-png.png" , "image/jxl" },
476+ {"animated.gif" , "" },
477+ {"transparent-png-use-original.png" , "image/jxl" },
478+ {"logo.png" , "image/jxl" },
479+ })
480+ }
481+
482+ func TestImageMagickProcessor_FitToSize_Jxl (t * testing.T ) {
375483 testImages (t , func (orig []byte , imgId string ) (* img.Image , error ) {
376484 return proc .FitToSize (& img.TransformationConfig {
377485 Src : & img.Image {
378486 Id : imgId ,
379487 Data : orig ,
380488 },
381- SupportedFormats : []string {"image/avif " },
489+ SupportedFormats : []string {"image/jxl " },
382490 Config : & img.ResizeConfig {Size : "50x50" },
383491 })
384492 },
385493 []* testTransformation {
386- {"big-jpeg.jpg" , "image/avif " },
387- {"medium-jpeg.jpg" , "image/avif " },
388- {"opaque-png.png" , "image/avif " },
494+ {"big-jpeg.jpg" , "image/jxl " },
495+ {"medium-jpeg.jpg" , "image/jxl " },
496+ {"opaque-png.png" , "image/jxl " },
389497 {"animated.gif" , "" },
390498 {"animated-coalesce.gif" , "" },
391- {"transparent-png-use-original.png" , "" },
392- {"logo.png" , "" },
499+ {"transparent-png-use-original.png" , "image/jxl " },
500+ {"logo.png" , "image/jxl " },
393501 })
394502}
395503
0 commit comments