mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Merge pull request #163 from ronaldoussoren/master
Issue 161: import JpegPresets from PIL
This commit is contained in:
commit
34c9cc6235
|
@ -36,7 +36,7 @@ __version__ = "0.6"
|
||||||
|
|
||||||
import array, struct
|
import array, struct
|
||||||
from PIL import Image, ImageFile, _binary
|
from PIL import Image, ImageFile, _binary
|
||||||
from JpegPresets import presets
|
from PIL.JpegPresets import presets
|
||||||
|
|
||||||
i8 = _binary.i8
|
i8 = _binary.i8
|
||||||
o8 = _binary.o8
|
o8 = _binary.o8
|
||||||
|
@ -483,7 +483,7 @@ def _save(im, fp, filename):
|
||||||
elif subsampling == "keep":
|
elif subsampling == "keep":
|
||||||
if im.format != "JPEG":
|
if im.format != "JPEG":
|
||||||
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
||||||
subsampling = get_sampling(im)
|
subsampling = get_sampling(im)
|
||||||
|
|
||||||
def validate_qtables(qtables):
|
def validate_qtables(qtables):
|
||||||
if qtables is None:
|
if qtables is None:
|
||||||
|
@ -513,7 +513,7 @@ def _save(im, fp, filename):
|
||||||
else:
|
else:
|
||||||
qtables[idx] = list(table)
|
qtables[idx] = list(table)
|
||||||
return qtables
|
return qtables
|
||||||
|
|
||||||
if qtables == "keep":
|
if qtables == "keep":
|
||||||
if im.format != "JPEG":
|
if im.format != "JPEG":
|
||||||
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
raise ValueError("Cannot use 'keep' when original image is not a JPEG")
|
||||||
|
@ -560,7 +560,7 @@ def _save(im, fp, filename):
|
||||||
# https://github.com/jdriscoll/django-imagekit/issues/50
|
# https://github.com/jdriscoll/django-imagekit/issues/50
|
||||||
bufsize=0
|
bufsize=0
|
||||||
if "optimize" in info:
|
if "optimize" in info:
|
||||||
bufsize = im.size[0]*im.size[1]
|
bufsize = im.size[0]*im.size[1]
|
||||||
|
|
||||||
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
|
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)], bufsize)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user