Skip to content

Commit 7340642

Browse files
add transform and crs for tiff outputs (#1238)
1 parent 577ff7e commit 7340642

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* add `grayscale` and `bitonal` algorithms
6+
* add `transform` and `crs` for `tiff` outputs
67

78
## 0.24.0 (2025-09-23)
89

src/titiler/core/tests/test_factories.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,13 +2126,26 @@ def test_ogc_maps_cog():
21262126
assert "Content-Bbox" in headers
21272127
assert "Content-Crs" in headers
21282128
assert headers["content-type"] == "image/jpeg"
2129+
meta = parse_img(response.content)
2130+
assert not meta["crs"]
2131+
2132+
response = client.get("/map", params={"url": cog_path, "f": "tif"})
2133+
assert response.status_code == 200
2134+
headers = response.headers
2135+
assert "Content-Bbox" in headers
2136+
assert "Content-Crs" in headers
2137+
assert headers["content-type"] == "image/tiff; application=geotiff"
2138+
meta = parse_img(response.content)
2139+
assert meta["crs"]
21292140

21302141
response = client.get("/map", params={"url": cog_path, "f": "tiff"})
21312142
assert response.status_code == 200
21322143
headers = response.headers
21332144
assert "Content-Bbox" in headers
21342145
assert "Content-Crs" in headers
21352146
assert headers["content-type"] == "image/tiff; application=geotiff"
2147+
meta = parse_img(response.content)
2148+
assert meta["crs"]
21362149

21372150
# Conformance Class “Scaling”
21382151
# /req/scaling/width-definition

src/titiler/core/titiler/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def render_image( # noqa: C901
108108
data = rescale_array(data, mask, in_range=datatype_range)
109109

110110
creation_options = {**kwargs, **output_format.profile}
111-
if output_format == ImageType.tif:
111+
if output_format.driver == "GTiff":
112112
if "transform" not in creation_options:
113113
creation_options.update({"transform": image.transform})
114114
if "crs" not in creation_options and image.crs:

0 commit comments

Comments
 (0)