Skip to content

Commit

Permalink
flask_iiif: addition of TIFF format default support
Browse files Browse the repository at this point in the history
* NEW Adds TIFF image support to the default config.

Signed-off-by: Alexander Ioannidis <[email protected]>
  • Loading branch information
slint authored and drjova committed Apr 11, 2017
1 parent f038f4a commit e4ff135
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Contributors
* Harris Tzovanakis <[email protected]>
* Jiri Kuncar <[email protected]>
* Tibor Simko <[email protected]>
* Alexander Ioannidis <[email protected]>
4 changes: 2 additions & 2 deletions flask_iiif/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def save(self, path, image_format="jpeg", quality=90):
"""Store the image to the specific path.
:param str path: absolute path
:param str image_format: (gif, jpeg, pdf, png)
:param str image_format: (gif, jpeg, pdf, png, tif)
:param int quality: The image quality; [1, 100]
.. note::
Expand All @@ -367,7 +367,7 @@ def save(self, path, image_format="jpeg", quality=90):
def serve(self, image_format="png", quality=90):
"""Return a BytesIO object to easily serve it thought HTTTP.
:param str image_format: (gif, jpeg, pdf, png)
:param str image_format: (gif, jpeg, pdf, png, tif)
:param int quality: The image quality; [1, 100]
.. note::
Expand Down
5 changes: 3 additions & 2 deletions flask_iiif/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
'jpg': 'image/jpeg',
'pdf': 'application/pdf',
'png': 'image/png',
'tif': 'image/tiff',
}

# Regular expressions to validate each parameter
Expand All @@ -107,7 +108,7 @@
},
"image_format": {
"ignore": "",
"validate": "(jpg|png|gif|jp2|jpeg|pdf)"
"validate": "(jpg|png|gif|jp2|jpeg|pdf|tif)"
}
},
"v2": {
Expand All @@ -130,7 +131,7 @@
},
"image_format": {
"ignore": "",
"validate": "(jpg|png|gif|jp2|jpeg|pdf)"
"validate": "(jpg|png|gif|jp2|jpeg|pdf|tif)"
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/test_multimedia_image_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def setUp(self):
tmp_file.seek(0)
self.image_p_mode = MultimediaImage.from_string(tmp_file)

# TIFF Image
tmp_file = BytesIO()
image = Image.new("RGBA", (1280, 1024), (255, 0, 0, 0))
image.save(tmp_file, 'tiff')
tmp_file.seek(0)
self.image_tiff = MultimediaImage.from_string(tmp_file)

def test_image_resize(self):
"""Test image resize function."""
# Test image size before
Expand Down Expand Up @@ -184,3 +191,7 @@ def test_image_saving(self):
self.assertEqual(tmp_file.getvalue(), compare_file.getvalue())
self.image_save.save(tmp_file)
self.assertNotEqual(str(tmp_file.getvalue()), compare_file.getvalue())

def test_image_tiff_support(self):
"""Test TIFF image support."""
self.assertEqual(self.image_tiff.image.format, 'TIFF')

0 comments on commit e4ff135

Please sign in to comment.