mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Added register_extensions method
This commit is contained in:
parent
39df75bd07
commit
567351f632
|
@ -418,7 +418,6 @@ Image.register_open(EpsImageFile.format, EpsImageFile, _accept)
|
|||
|
||||
Image.register_save(EpsImageFile.format, _save)
|
||||
|
||||
Image.register_extension(EpsImageFile.format, ".ps")
|
||||
Image.register_extension(EpsImageFile.format, ".eps")
|
||||
Image.register_extensions(EpsImageFile.format, [".ps", ".eps"])
|
||||
|
||||
Image.register_mime(EpsImageFile.format, "application/postscript")
|
||||
|
|
|
@ -72,5 +72,4 @@ def _save(im, fp, filename):
|
|||
Image.register_open(FITSStubImageFile.format, FITSStubImageFile, _accept)
|
||||
Image.register_save(FITSStubImageFile.format, _save)
|
||||
|
||||
Image.register_extension(FITSStubImageFile.format, ".fit")
|
||||
Image.register_extension(FITSStubImageFile.format, ".fits")
|
||||
Image.register_extensions(FITSStubImageFile.format, [".fit", ".fits"])
|
||||
|
|
|
@ -162,5 +162,4 @@ class FliImageFile(ImageFile.ImageFile):
|
|||
|
||||
Image.register_open(FliImageFile.format, FliImageFile, _accept)
|
||||
|
||||
Image.register_extension(FliImageFile.format, ".fli")
|
||||
Image.register_extension(FliImageFile.format, ".flc")
|
||||
Image.register_extensions(FliImageFile.format, [".fli", ".flc"])
|
||||
|
|
|
@ -91,5 +91,4 @@ def _validate(prefix):
|
|||
|
||||
|
||||
Image.register_open(FtexImageFile.format, FtexImageFile, _validate)
|
||||
Image.register_extension(FtexImageFile.format, ".ftc")
|
||||
Image.register_extension(FtexImageFile.format, ".ftu")
|
||||
Image.register_extensions(FtexImageFile.format, [".ftc", ".ftu"])
|
||||
|
|
|
@ -69,5 +69,4 @@ def _save(im, fp, filename):
|
|||
Image.register_open(HDF5StubImageFile.format, HDF5StubImageFile, _accept)
|
||||
Image.register_save(HDF5StubImageFile.format, _save)
|
||||
|
||||
Image.register_extension(HDF5StubImageFile.format, ".h5")
|
||||
Image.register_extension(HDF5StubImageFile.format, ".hdf")
|
||||
Image.register_extensions(HDF5StubImageFile.format, [".h5", ".hdf"])
|
||||
|
|
10
PIL/Image.py
10
PIL/Image.py
|
@ -2728,6 +2728,16 @@ def register_extension(id, extension):
|
|||
"""
|
||||
EXTENSION[extension.lower()] = id.upper()
|
||||
|
||||
def register_extensions(id, extensions):
|
||||
"""
|
||||
Registers image extensions. This function should not be
|
||||
used in application code.
|
||||
|
||||
:param id: An image format identifier.
|
||||
:param extensions: A list of extensions used for this format.
|
||||
"""
|
||||
for extension in extensions:
|
||||
register_extension(id, extension)
|
||||
|
||||
def registered_extensions():
|
||||
"""
|
||||
|
|
|
@ -269,12 +269,7 @@ def _save(im, fp, filename):
|
|||
Image.register_open(Jpeg2KImageFile.format, Jpeg2KImageFile, _accept)
|
||||
Image.register_save(Jpeg2KImageFile.format, _save)
|
||||
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.jp2')
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.j2k')
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.jpc')
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.jpf')
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.jpx')
|
||||
Image.register_extension(Jpeg2KImageFile.format, '.j2c')
|
||||
Image.register_extensions(Jpeg2KImageFile.format, [".jp2", ".j2k", ".jpc", ".jpf", ".jpx", ".j2c"])
|
||||
|
||||
Image.register_mime(Jpeg2KImageFile.format, 'image/jp2')
|
||||
Image.register_mime(Jpeg2KImageFile.format, 'image/jpx')
|
||||
|
|
|
@ -783,9 +783,6 @@ def jpeg_factory(fp=None, filename=None):
|
|||
Image.register_open(JpegImageFile.format, jpeg_factory, _accept)
|
||||
Image.register_save(JpegImageFile.format, _save)
|
||||
|
||||
Image.register_extension(JpegImageFile.format, ".jfif")
|
||||
Image.register_extension(JpegImageFile.format, ".jpe")
|
||||
Image.register_extension(JpegImageFile.format, ".jpg")
|
||||
Image.register_extension(JpegImageFile.format, ".jpeg")
|
||||
Image.register_extensions(JpegImageFile.format, [".jfif", ".jpe", ".jpg", ".jpeg"])
|
||||
|
||||
Image.register_mime(JpegImageFile.format, "image/jpeg")
|
||||
|
|
|
@ -80,7 +80,6 @@ class MpegImageFile(ImageFile.ImageFile):
|
|||
|
||||
Image.register_open(MpegImageFile.format, MpegImageFile)
|
||||
|
||||
Image.register_extension(MpegImageFile.format, ".mpg")
|
||||
Image.register_extension(MpegImageFile.format, ".mpeg")
|
||||
Image.register_extensions(MpegImageFile.format, [".mpg", ".mpeg"])
|
||||
|
||||
Image.register_mime(MpegImageFile.format, "video/mpeg")
|
||||
|
|
|
@ -164,6 +164,4 @@ def _save(im, fp, filename):
|
|||
Image.register_open(PpmImageFile.format, PpmImageFile, _accept)
|
||||
Image.register_save(PpmImageFile.format, _save)
|
||||
|
||||
Image.register_extension(PpmImageFile.format, ".pbm")
|
||||
Image.register_extension(PpmImageFile.format, ".pgm")
|
||||
Image.register_extension(PpmImageFile.format, ".ppm")
|
||||
Image.register_extensions(PpmImageFile.format, [".pbm", ".pgm", ".ppm"])
|
||||
|
|
|
@ -149,9 +149,7 @@ 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_extension(SgiImageFile.format, ".bw")
|
||||
Image.register_extension(SgiImageFile.format, ".rgb")
|
||||
Image.register_extension(SgiImageFile.format, ".rgba")
|
||||
Image.register_extension(SgiImageFile.format, ".sgi")
|
||||
|
||||
Image.register_extensions(SgiImageFile.format, [".bw", ".rgb", ".rgba", ".sgi"])
|
||||
|
||||
# End of file
|
||||
|
|
|
@ -1792,7 +1792,6 @@ Image.register_open(TiffImageFile.format, TiffImageFile, _accept)
|
|||
Image.register_save(TiffImageFile.format, _save)
|
||||
Image.register_save_all(TiffImageFile.format, _save_all)
|
||||
|
||||
Image.register_extension(TiffImageFile.format, ".tif")
|
||||
Image.register_extension(TiffImageFile.format, ".tiff")
|
||||
Image.register_extensions(TiffImageFile.format, [".tif", ".tiff"])
|
||||
|
||||
Image.register_mime(TiffImageFile.format, "image/tiff")
|
||||
|
|
|
@ -164,5 +164,4 @@ def _save(im, fp, filename):
|
|||
Image.register_open(WmfStubImageFile.format, WmfStubImageFile, _accept)
|
||||
Image.register_save(WmfStubImageFile.format, _save)
|
||||
|
||||
Image.register_extension(WmfStubImageFile.format, ".wmf")
|
||||
Image.register_extension(WmfStubImageFile.format, ".emf")
|
||||
Image.register_extensions(WmfStubImageFile.format, [".wmf", ".emf"])
|
||||
|
|
Loading…
Reference in New Issue
Block a user