From 8afc2c4c391c998088571c199d8da11a09624e70 Mon Sep 17 00:00:00 2001 From: Aleksandr Pikeev Date: Sat, 23 Mar 2024 20:53:59 +0300 Subject: [PATCH] feat: add image formats --- chrome.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chrome.go b/chrome.go index a534e6b..78f1e14 100644 --- a/chrome.go +++ b/chrome.go @@ -19,6 +19,7 @@ const ( scale string = "scale" skipNetworkIdleEvent string = "skipNetworkIdleEvent" singlePage string = "singlePage" + format string = "format" ) // nolint: gochecknoglobals @@ -49,6 +50,13 @@ var ( LargeMargins = [4]float64{2, 2, 2, 2} ) +// nolint: gochecknoglobals +var ( + PNG = "png" + JPEG = "jpeg" + WebP = "webp" +) + type chromeRequest struct { header Document footer Document @@ -119,3 +127,11 @@ func (req *chromeRequest) SkipNetworkIdleEvent() { func (req *chromeRequest) SinglePage() { req.values[singlePage] = "true" } + +// Format sets format form field +func (req *chromeRequest) Format(format string) { + req.values[format] = format + if format == "" { + req.values[format] = JPEG + } +}