If SGI image is RGB mode, then apply image/rgb mimetype

This commit is contained in:
Andrew Murray 2019-01-02 12:45:07 +11:00
parent 97ae0c42b1
commit 42e2bed4a6
2 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ class TestFileSgi(PillowTestCase):
im = Image.open(test_file)
self.assert_image_equal(im, hopper())
self.assertEqual(im.get_format_mimetype(), 'image/rgb')
def test_rgb16(self):
test_file = "Tests/images/hopper16.rgb"
@ -26,6 +27,7 @@ class TestFileSgi(PillowTestCase):
im = Image.open(test_file)
self.assert_image_similar(im, hopper('L'), 2)
self.assertEqual(im.get_format_mimetype(), 'image/sgi')
def test_rgba(self):
# Created with ImageMagick:
@ -35,6 +37,7 @@ class TestFileSgi(PillowTestCase):
im = Image.open(test_file)
target = Image.open('Tests/images/transparent.png')
self.assert_image_equal(im, target)
self.assertEqual(im.get_format_mimetype(), 'image/sgi')
def test_rle(self):
# Created with ImageMagick:

View File

@ -98,6 +98,8 @@ class SgiImageFile(ImageFile.ImageFile):
self._size = xsize, ysize
self.mode = rawmode.split(";")[0]
if self.mode == 'RGB':
self.custom_mimetype = 'image/rgb'
# orientation -1 : scanlines begins at the bottom-left corner
orientation = -1
@ -220,7 +222,6 @@ Image.register_decoder("SGI16", SGI16Decoder)
Image.register_open(SgiImageFile.format, SgiImageFile, _accept)
Image.register_save(SgiImageFile.format, _save)
Image.register_mime(SgiImageFile.format, "image/sgi")
Image.register_mime(SgiImageFile.format, "image/rgb")
Image.register_extensions(SgiImageFile.format,
[".bw", ".rgb", ".rgba", ".sgi"])