PIL 套件 (剩餘模組的自動文件)¶
此處提供尚未移植或撰寫文件的模組參考。
PIL
模組¶
- exception PIL.UnidentifiedImageError[來源]¶
基底類別:
OSError
如果無法開啟和識別圖像,則會在
PIL.Image.open()
中引發此錯誤。如果 PNG 圖像引發此錯誤,則將
ImageFile.LOAD_TRUNCATED_IMAGES
設定為 true 後,或許仍然可以開啟圖像。此設定會忽略遺失的資料和檢查碼失敗。
BdfFontFile
模組¶
剖析 X Bitmap Distribution Format (BDF)
ContainerIO
模組¶
- class PIL.ContainerIO.ContainerIO(file: IO, offset: int, length: int)[原始碼]¶
繼承自:
IO
一個檔案物件,提供對現有檔案的一部分進行讀取存取的功能 (例如 TAR 檔案)。
- readlines(n: int | None = -1) list[AnyStr] [原始碼]¶
讀取多行文字。
- 參數:
n – 要讀取的行數。 如果省略、零、負數或 None,則讀取到區域末端。
- 回傳:
一個 8 位元字串列表。
FontFile
模組¶
GdImageFile
模組¶
注意
此格式無法自動辨識,因此該類別未註冊以與 PIL.Image.open()
一起使用。若要開啟 gd 檔案,請改用 PIL.GdImageFile.open()
函式。
警告
GD 格式並非設計用於資料交換。此實作僅為方便和示範之用。
- class PIL.GdImageFile.GdImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[原始碼]¶
基底類別:
ImageFile
用於 GD 未壓縮格式的影像外掛程式。請注意,標準
PIL.Image.open()
函式不支援此格式。若要使用此外掛程式,您必須匯入PIL.GdImageFile
模組並使用PIL.GdImageFile.open()
函式。
- PIL.GdImageFile.open(fp: StrOrBytesPath | IO[bytes], mode: str = 'r') GdImageFile [原始碼]¶
從 GD 影像檔載入紋理。
- 參數:
fp – GD 檔名或已開啟的檔案控制代碼。
mode – 選用模式。在此版本中,如果提供模式引數,則必須為「r」。
- 回傳:
一個影像實例。
- 引發:
OSError – 如果無法讀取影像。
GimpGradientFile
模組¶
將曲線線段轉換為調色盤數值的內容(衍生自 GIMP 中對應的程式碼,由 Federico Mena Quintero 編寫。如需更多資訊,請參閱 GIMP 發行版。)
- PIL.GimpGradientFile.EPSILON = 1e-10¶
- class PIL.GimpGradientFile.GimpGradientFile(fp: IO[bytes])[原始碼]¶
基底類別:
GradientFile
GIMP 漸層格式的檔案處理程式。
- PIL.GimpGradientFile.SEGMENTS = [<function linear>, <function curved>, <function sine>, <function sphere_increasing>, <function sphere_decreasing>]¶
GimpPaletteFile
模組¶
ImageDraw2
模組¶
(實驗性) WCK 風格的繪圖介面操作
另請參閱
- 類別 PIL.ImageDraw2.Font(color: str, file: StrOrBytesPath | BinaryIO, size: float = 12)[原始碼]¶
基底類別:
object
儲存 TrueType 字型和顏色
- 類別 PIL.ImageDraw2.Draw(image: Image | str, size: tuple[int, int] | list[int] | None = None, color: float | tuple[float, ...] | str | None = None)[原始碼]¶
基底類別:
object
(實驗性) WCK 風格繪圖介面
- render(op: str, xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, brush: Brush | Pen | None = None, **kwargs: Any) None [原始碼]¶
- arc(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, start: float, end: float, *options: Any) None [原始碼]¶
在給定的邊界框內,繪製起點和終點角度之間的弧線(圓形輪廓的一部分)。
- chord(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, start: float, end: float, *options: Any) None [原始碼]¶
與
arc()
相同,但會用直線連接端點。
- ellipse(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, *options: Any) None [原始碼]¶
在給定的邊界框內繪製橢圓。
- line(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, *options: Any) None [原始碼]¶
在
xy
清單中的座標之間繪製一條線。
- pieslice(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, start: float, end: float, *options: Any) None [原始碼]¶
與 arc 相同,但也會在邊界框的端點與中心之間繪製直線。
- polygon(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, *options: Any) None [原始碼]¶
繪製多邊形。
多邊形輪廓由給定座標之間的直線組成,加上最後一個和第一個座標之間的直線。
- rectangle(xy: Sequence[float] | Sequence[Sequence[float]], pen: Pen | Brush | None, *options: Any) None [原始碼]¶
繪製矩形。
ImageMode
模組¶
- class PIL.ImageMode.ModeDescriptor(mode: str, bands: tuple[str, ...], basemode: str, basetype: str, typestr: str)[原始碼]¶
基礎類別:
NamedTuple
模式字串的包裝器。
- PIL.ImageMode.getmode(mode: str) ModeDescriptor [原始碼]¶
取得給定模式的模式描述器。
PaletteFile
模組¶
PcfFontFile
模組¶
PngImagePlugin.iTXt
類別¶
PngImagePlugin.PngInfo
類別¶
- class PIL.PngImagePlugin.PngInfo[原始碼]¶
基底類別:
object
PNG 區塊容器 (用於 save(pnginfo=))
- add(cid: bytes, data: bytes, after_idat: bool = False) None [原始碼]¶
附加任意區塊。請謹慎使用。
- 參數:
cid – 一個位元組字串,長度為 4 個位元組。
data – 編碼資料的位元組字串
after_idat – 用於私有區塊。是否應在 IDAT 之後寫入區塊
TarIO
模組¶
WalImageFile
模組¶
此讀取器基於以下規格: https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml,並已使用 google 找到的一些範例檔案進行測試。
注意
此格式無法自動辨識,因此讀取器未註冊以用於 PIL.Image.open()
。若要開啟 WAL 檔案,請改用 PIL.WalImageFile.open()
函式。
- class PIL.WalImageFile.WalImageFile(fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None)[原始碼]¶
基底類別:
ImageFile
- load() Image.core.PixelAccess | None [原始碼]¶
根據圖塊列表載入影像資料
- PIL.WalImageFile.open(filename: StrOrBytesPath | IO[bytes]) WalImageFile [原始碼]¶
從 Quake2 WAL 紋理檔案載入紋理。
預設情況下,Quake2 標準調色盤會附加到紋理。若要覆寫調色盤,請使用
PIL.Image.Image.putpalette()
方法。- 參數:
filename – WAL 檔案名稱或已開啟的檔案控制代碼。
- 回傳:
一個影像實例。