From 8fa122847977effa40fbf7562a6fa22430bf8114 Mon Sep 17 00:00:00 2001
From: Impact <pascal.mouquet@ird.fr>
Date: Mon, 20 Jan 2020 09:48:13 +0400
Subject: [PATCH] adding new small jpg QL

---
 sen2chain/colormap.py | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/sen2chain/colormap.py b/sen2chain/colormap.py
index 57d0c42..547ff4d 100644
--- a/sen2chain/colormap.py
+++ b/sen2chain/colormap.py
@@ -322,15 +322,29 @@ def create_l2a_ql(b02: Union[str, pathlib.PosixPath],
             src.height,
             *src.bounds,
             resolution=out_resolution)
-        
-    profile.update(nodata=0,
-        driver="Gtiff",
-        dtype=np.uint8,
-        transform=dst_transform,
-        width=dst_width,
-        height=dst_height,
-        tiled=False,
-        count=len(file_list))
+    
+    if out_path.suffix == ".jpg":
+        profile.update(nodata=0,
+                       driver="JPEG",
+                       dtype=np.uint8,
+                       transform=dst_transform,
+                       width=dst_width,
+                       height=dst_height,
+                       tiled=False,
+                       count=len(file_list))
+        profile.pop('tiled', None)
+        profile.pop('blockxsize', None)
+        profile.pop('blockysize', None)
+
+    else:
+        profile.update(nodata=0,
+                       driver="Gtiff",
+                       dtype=np.uint8,
+                       transform=dst_transform,
+                       width=dst_width,
+                       height=dst_height,
+                       tiled=False,
+                       count=len(file_list))
 
     with rasterio.open(str(out_path), 'w', **profile) as dst:
         for id, layer in enumerate(file_list, start=1):
-- 
GitLab