Skip to content

Commit 287201a

Browse files
add support for jpeg and jpg (#271)
* add support for jpeg and jpg * update changelog
1 parent ab53427 commit 287201a

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## Next (TBD)
4+
5+
* add support for `.jpg` and `.jpeg` extensions (https://github.com/developmentseed/titiler/pull/271)
6+
37
## 0.2.0 (2021-03-09)
48

59
* adapt for cogeo-mosaic `3.0.0rc2` and add `backend_options` attribute in MosaicTilerFactory (https://github.com/developmentseed/titiler/pull/247)

docs/concepts/output_format.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Default output types/extensions are:
1212
* `.jp2`: image/jp2
1313
* `.png`: image/png
1414
* `.pngraw`: image/png
15-
* `.jpg`: image/jpeg
15+
* `.jpeg`: image/jpeg
16+
* `.jpg`: image/jpg
1617
* `.webp`: image/webp
1718
* `.npy`: application/x-binary
1819

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"python-dotenv",
1818
"rasterio",
1919
"rio-cogeo>=2.1,<2.2",
20-
"rio-tiler>=2.0.4,<2.1",
20+
"rio-tiler>=2.0.5,<2.1",
2121
"uvicorn[standard]>=0.12.0,<0.14.0",
2222
# Additional requirements for python 3.6
2323
"dataclasses;python_version<'3.7'",

tests/routes/test_cog.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,19 @@ def test_tile(rio, app):
146146
"/cog/tiles/8/87/48.jpg?url=https://myurl.com/cog.tif&rescale=0,1000"
147147
)
148148
assert response.status_code == 200
149+
assert response.headers["content-type"] == "image/jpg"
150+
151+
response = app.get(
152+
"/cog/tiles/8/87/48.jpeg?url=https://myurl.com/cog.tif&rescale=0,1000"
153+
)
154+
assert response.status_code == 200
149155
assert response.headers["content-type"] == "image/jpeg"
150156

151157
response = app.get(
152158
"/cog/tiles/8/87/[email protected]?url=https://myurl.com/cog.tif&rescale=0,1000"
153159
)
154160
assert response.status_code == 200
155-
assert response.headers["content-type"] == "image/jpeg"
161+
assert response.headers["content-type"] == "image/jpg"
156162

157163
response = app.get(
158164
"/cog/tiles/8/87/[email protected]?url=https://myurl.com/cog.tif&nodata=0&bidx=1"
@@ -376,7 +382,7 @@ def test_part(rio, app):
376382
"/cog/crop/-56.228,72.715,-54.547,73.188.jpg?url=https://myurl.com/cog.tif&rescale=0,1000&max_size=256&return_mask=false"
377383
)
378384
assert response.status_code == 200
379-
assert response.headers["content-type"] == "image/jpeg"
385+
assert response.headers["content-type"] == "image/jpg"
380386
meta = parse_img(response.content)
381387
assert meta["count"] == 1
382388
assert meta["width"] == 256

tests/routes/test_mosaic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_tile(app):
166166
},
167167
)
168168
assert response.status_code == 200
169-
assert response.headers["content-type"] == "image/jpeg"
169+
assert response.headers["content-type"] == "image/jpg"
170170

171171
# partial tile
172172
response = app.get(

tests/test_enums.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
("png", "PNG", "image/png"),
1313
("npy", "NPY", "application/x-binary"),
1414
("tif", "GTiff", "image/tiff; application=geotiff"),
15+
("jpg", "JPEG", "image/jpg"),
1516
("jpeg", "JPEG", "image/jpeg"),
1617
("jp2", "JP2OpenJPEG", "image/jp2"),
1718
("webp", "WEBP", "image/webp"),
@@ -28,5 +29,6 @@ def test_imageprofile():
2829
"""test image profile."""
2930
ImageType.png.profile == img_profiles.get("png")
3031
ImageType.pngraw.profile == img_profiles.get("pngraw")
32+
ImageType.jpg.profile == img_profiles.get("jpg")
3133
ImageType.jpeg.profile == img_profiles.get("jpeg")
3234
ImageType.webp.profile == img_profiles.get("webp")

titiler/resources/enums.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class MediaType(str, Enum):
1515
png = "image/png"
1616
pngraw = "image/png"
1717
jpeg = "image/jpeg"
18+
jpg = "image/jpg"
1819
webp = "image/webp"
1920
npy = "application/x-binary"
2021
xml = "application/xml"
@@ -28,6 +29,7 @@ class ImageDriver(str, Enum):
2829
"""Supported output GDAL drivers."""
2930

3031
jpeg = "JPEG"
32+
jpg = "JPEG"
3133
png = "PNG"
3234
pngraw = "PNG"
3335
tif = "GTiff"
@@ -42,7 +44,8 @@ class ImageType(str, Enum):
4244
png = "png"
4345
npy = "npy"
4446
tif = "tif"
45-
jpeg = "jpg"
47+
jpeg = "jpeg"
48+
jpg = "jpg"
4649
jp2 = "jp2"
4750
webp = "webp"
4851
pngraw = "pngraw"

0 commit comments

Comments
 (0)