From f7ad58de119a6b1f2e90d7b8c32350e06cf9c674 Mon Sep 17 00:00:00 2001 From: baskara Date: Sun, 19 Jan 2020 14:00:36 +0700 Subject: [PATCH] Hardcode the overlay result to be a PNG instead of following the original base image format --- .../overlay/{overlay_1.jpg => overlay_1.png} | Bin .../{overlay_19.jpg => overlay_19.png} | Bin .../overlay/{overlay_2.jpg => overlay_2.png} | Bin .../overlay/{overlay_3.jpg => overlay_3.png} | Bin .../overlay/{overlay_4.jpg => overlay_4.png} | Bin .../overlay/{overlay_5.jpg => overlay_5.png} | Bin .../overlay/{overlay_6.jpg => overlay_6.png} | Bin .../overlay/{overlay_7.jpg => overlay_7.png} | Bin .../overlay/{overlay_8.jpg => overlay_8.png} | Bin .../overlay/{overlay_9.jpg => overlay_9.png} | Bin pkg/processor/native/processor.go | 2 +- pkg/processor/native/processor_test.go | 20 +++++++++--------- 12 files changed, 11 insertions(+), 11 deletions(-) rename pkg/processor/native/_testdata/overlay/{overlay_1.jpg => overlay_1.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_19.jpg => overlay_19.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_2.jpg => overlay_2.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_3.jpg => overlay_3.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_4.jpg => overlay_4.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_5.jpg => overlay_5.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_6.jpg => overlay_6.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_7.jpg => overlay_7.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_8.jpg => overlay_8.png} (100%) rename pkg/processor/native/_testdata/overlay/{overlay_9.jpg => overlay_9.png} (100%) diff --git a/pkg/processor/native/_testdata/overlay/overlay_1.jpg b/pkg/processor/native/_testdata/overlay/overlay_1.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_1.jpg rename to pkg/processor/native/_testdata/overlay/overlay_1.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_19.jpg b/pkg/processor/native/_testdata/overlay/overlay_19.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_19.jpg rename to pkg/processor/native/_testdata/overlay/overlay_19.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_2.jpg b/pkg/processor/native/_testdata/overlay/overlay_2.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_2.jpg rename to pkg/processor/native/_testdata/overlay/overlay_2.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_3.jpg b/pkg/processor/native/_testdata/overlay/overlay_3.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_3.jpg rename to pkg/processor/native/_testdata/overlay/overlay_3.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_4.jpg b/pkg/processor/native/_testdata/overlay/overlay_4.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_4.jpg rename to pkg/processor/native/_testdata/overlay/overlay_4.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_5.jpg b/pkg/processor/native/_testdata/overlay/overlay_5.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_5.jpg rename to pkg/processor/native/_testdata/overlay/overlay_5.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_6.jpg b/pkg/processor/native/_testdata/overlay/overlay_6.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_6.jpg rename to pkg/processor/native/_testdata/overlay/overlay_6.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_7.jpg b/pkg/processor/native/_testdata/overlay/overlay_7.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_7.jpg rename to pkg/processor/native/_testdata/overlay/overlay_7.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_8.jpg b/pkg/processor/native/_testdata/overlay/overlay_8.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_8.jpg rename to pkg/processor/native/_testdata/overlay/overlay_8.png diff --git a/pkg/processor/native/_testdata/overlay/overlay_9.jpg b/pkg/processor/native/_testdata/overlay/overlay_9.png similarity index 100% rename from pkg/processor/native/_testdata/overlay/overlay_9.jpg rename to pkg/processor/native/_testdata/overlay/overlay_9.png diff --git a/pkg/processor/native/processor.go b/pkg/processor/native/processor.go index 05b08ed..70cafb5 100644 --- a/pkg/processor/native/processor.go +++ b/pkg/processor/native/processor.go @@ -236,7 +236,7 @@ func (bp *BildProcessor) Overlay(base []byte, overlays []*processor.OverlayAttrs } } - return bp.Encode(baseImg, f) + return bp.Encode(baseImg, processor.ExtensionPNG) } // WithEncoders is a builder function to set custom Encoders for BildProcessor diff --git a/pkg/processor/native/processor_test.go b/pkg/processor/native/processor_test.go index 44bd39d..192a36c 100644 --- a/pkg/processor/native/processor_test.go +++ b/pkg/processor/native/processor_test.go @@ -293,7 +293,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { overlays: []*processor.OverlayAttrs{}, }, { - expected: "./_testdata/overlay/overlay_1.jpg", + expected: "./_testdata/overlay/overlay_1.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -304,7 +304,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_2.jpg", + expected: "./_testdata/overlay/overlay_2.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -315,7 +315,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_3.jpg", + expected: "./_testdata/overlay/overlay_3.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -326,7 +326,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_4.jpg", + expected: "./_testdata/overlay/overlay_4.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -337,7 +337,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_5.jpg", + expected: "./_testdata/overlay/overlay_5.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -348,7 +348,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_6.jpg", + expected: "./_testdata/overlay/overlay_6.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -359,7 +359,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_7.jpg", + expected: "./_testdata/overlay/overlay_7.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -370,7 +370,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_8.jpg", + expected: "./_testdata/overlay/overlay_8.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -381,7 +381,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_9.jpg", + expected: "./_testdata/overlay/overlay_9.png", overlays: []*processor.OverlayAttrs{ { Img: overlay, @@ -392,7 +392,7 @@ func (s *BildProcessorSuite) TestBildProcessor_Overlay() { }, }, { - expected: "./_testdata/overlay/overlay_19.jpg", + expected: "./_testdata/overlay/overlay_19.png", overlays: []*processor.OverlayAttrs{ { Img: overlay,