JPEG-PIL JPEG (ISO 10918)¶
扩展名:.jfif
, .jpe
, .jpg
, .jpeg
是基于Pillow的JPEG格式
此格式支持灰度、RGB和RGBA图像。
有关读取的参数¶
-
exifrotate
:
bool
- 根据exif信息自动旋转图像。默认值为True。 pilmode : str
-
From the Pillow documentation:
- ‘L’ (8-bit pixels, grayscale)
- ‘P’ (8-bit pixels, mapped to any other mode using a color palette)
- ‘RGB’ (3x8-bit pixels, true color)
- ‘RGBA’ (4x8-bit pixels, true color with transparency mask)
- ‘CMYK’ (4x8-bit pixels, color separation)
- ‘YCbCr’ (3x8-bit pixels, color video format)
- ‘I’ (32-bit signed integer pixels)
- ‘F’ (32-bit floating point pixels)
PIL同时提供几个特殊读取模式的支持,包括 ‘LA’ (‘L’ with alpha), ‘RGBX’ (true color with padding)和‘RGBa’ (true color with premultiplied alpha).
将彩色图转换为灰度图时,(mode ‘L’, ‘I’ or ‘F’), 使用 ITU-R 601-2 luma变换:
L = R * 299/1000 + G * 587/1000 + B * 114/1000
as_gray
:
bool
- 如果为True,影像以'F'模式被转换。当 mode 不是 None并且是 as_gray is True,影像首先根据 mode被读取,然后被 ‘F’模式“flattened”.
Parameters for saving¶
-
quality
:
scalar
- 压缩质量取值范围是(1..100),数值越大文件所占空间越大。默认值是75。. progressive : bool
- 保存为渐进式JPEG文件(例如网页图片)。 Default False. optimize : bool
- 保存时计算Huffman编码表(能减小一点文件大小)默认取False。 dpi : tuple of int
-
像素密度,
(x,y)
.
icc_profile
:
object
- 如果列出来且为true影像使用所提供的ICC色彩特性文件存储; 如果没有提供此参数,影像将不带色彩特性文件保存。 exif : dict
- 如果使用此参数,影像中将加入所提供的 EXIF 数据。 subsampling : str
- 设置编码器(encoder)的下采样(subsampling),详见Pillow文档。 qtables : object
- 设置编码器的qtables,详见Pillow文档。