Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Pillow (PIL Fork) 12.0.0 documentation
Light LogoDark Logo
Pillow (PIL Fork) 12.0.0 documentation
Back to top

PIL package (autodoc of remaining modules)

Reference for modules whose documentation has not yet been ported or writtencan be found here.

PIL module

exceptionPIL.UnidentifiedImageError[source]

Bases:OSError

Raised inPIL.Image.open() if an image cannot be opened and identified.

If a PNG image raises this error, settingImageFile.LOAD_TRUNCATED_IMAGESto true may allow the image to be opened after all. The setting will ignore missingdata and checksum failures.

BdfFontFile module

Parse X Bitmap Distribution Format (BDF)

classPIL.BdfFontFile.BdfFontFile(fp:BinaryIO)[source]

Bases:FontFile

Font file plugin for the X11 BDF format.

PIL.BdfFontFile.bdf_char(f:BinaryIO)tuple[str,int,tuple[tuple[int,int],tuple[int,int,int,int],tuple[int,int,int,int]],Image]|None[source]

ContainerIO module

classPIL.ContainerIO.ContainerIO(file:IO,offset:int,length:int)[source]

Bases:IO

A file object that provides read access to a part of an existingfile (for example a TAR file).

close()None[source]
fileno()int[source]
flush()None[source]
isatty()bool[source]
read(n:int=-1)AnyStr[source]

Read data.

Parameters:

n – Number of bytes to read. If omitted, zero or negative,read until end of region.

Returns:

An 8-bit string.

readable()bool[source]
readline(n:int=-1)AnyStr[source]

Read a line of text.

Parameters:

n – Number of bytes to read. If omitted, zero or negative,read until end of line.

Returns:

An 8-bit string.

readlines(n:int|None=-1)list[AnyStr][source]

Read multiple lines of text.

Parameters:

n – Number of lines to read. If omitted, zero, negative or None,read until end of region.

Returns:

A list of 8-bit strings.

seek(offset:int,mode:int=0)int[source]

Move file pointer.

Parameters:
  • offset – Offset in bytes.

  • mode – Starting position. Use 0 for beginning of region, 1for current offset, and 2 for end of region. You cannot movethe pointer outside the defined region.

Returns:

Offset from start of region, in bytes.

seekable()bool[source]
tell()int[source]

Get current file pointer.

Returns:

Offset from start of region, in bytes.

truncate(size:int|None=None)int[source]
writable()bool[source]
write(b:AnyStr)NoReturn[source]
writelines(lines:Iterable)NoReturn[source]

FontFile module

classPIL.FontFile.FontFile[source]

Bases:object

Base class for raster font file handlers.

bitmap:Image|None=None
compile()None[source]

Create metrics and bitmap

save(filename:str)None[source]

Save font

PIL.FontFile.puti16(fp:BinaryIO,values:tuple[int,int,int,int,int,int,int,int,int,int])None[source]

Write network order (big-endian) 16-bit sequence

GdImageFile module

Note

This format cannot be automatically recognized, so theclass is not registered for use withPIL.Image.open(). To open agd file, use thePIL.GdImageFile.open() function instead.

Warning

THE GD FORMAT IS NOT DESIGNED FOR DATA INTERCHANGE. Thisimplementation is provided for convenience and demonstrationalpurposes only.

classPIL.GdImageFile.GdImageFile(fp:StrOrBytesPath|IO[bytes],filename:str|bytes|None=None)[source]

Bases:ImageFile

Image plugin for the GD uncompressed format. Note that this formatis not supported by the standardPIL.Image.open() function. To usethis plugin, you have to import thePIL.GdImageFile module anduse thePIL.GdImageFile.open() function.

format:str|None='GD'
format_description:str|None='GDuncompressedimages'
PIL.GdImageFile.open(fp:str|bytes|PathLike[str]|PathLike[bytes]|IO[bytes],mode:str='r')GdImageFile[source]

Load texture from a GD image file.

Parameters:
  • fp – GD file name, or an opened file handle.

  • mode – Optional mode. In this version, if the mode argumentis given, it must be “r”.

Returns:

An image instance.

Raises:

OSError – If the image could not be read.

GimpGradientFile module

Stuff to translate curve segments to palette values (derived fromthe corresponding code in GIMP, written by Federico Mena Quintero.See the GIMP distribution for more information.)

PIL.GimpGradientFile.EPSILON=1e-10
classPIL.GimpGradientFile.GimpGradientFile(fp:IO[bytes])[source]

Bases:GradientFile

File handler for GIMP’s gradient format.

classPIL.GimpGradientFile.GradientFile[source]

Bases:object

getpalette(entries:int=256)tuple[bytes,str][source]
gradient:list[tuple[float,float,float,list[float],list[float],Callable[[float,float],float]]]|None=None
PIL.GimpGradientFile.SEGMENTS=[<functionlinear>,<functioncurved>,<functionsine>,<functionsphere_increasing>,<functionsphere_decreasing>]
PIL.GimpGradientFile.curved(middle:float,pos:float)float[source]
PIL.GimpGradientFile.linear(middle:float,pos:float)float[source]
PIL.GimpGradientFile.sine(middle:float,pos:float)float[source]
PIL.GimpGradientFile.sphere_decreasing(middle:float,pos:float)float[source]
PIL.GimpGradientFile.sphere_increasing(middle:float,pos:float)float[source]

GimpPaletteFile module

classPIL.GimpPaletteFile.GimpPaletteFile(fp:IO[bytes])[source]

Bases:object

File handler for GIMP’s palette format.

classmethodfrombytes(data:bytes)GimpPaletteFile[source]
getpalette()tuple[bytes,str][source]
rawmode='RGB'

ImageDraw2 module

(Experimental) WCK-style drawing interface operations

classPIL.ImageDraw2.Pen(color:str,width:int=1,opacity:int=255)[source]

Bases:object

Stores an outline color and width.

classPIL.ImageDraw2.Brush(color:str,opacity:int=255)[source]

Bases:object

Stores a fill color

classPIL.ImageDraw2.Font(color:str,file:str|bytes|PathLike[str]|PathLike[bytes]|BinaryIO,size:float=12)[source]

Bases:object

Stores a TrueType font and color

classPIL.ImageDraw2.Draw(image:Image|str,size:tuple[int,int]|list[int]|None=None,color:float|tuple[float,...]|str|None=None)[source]

Bases:object

(Experimental) WCK-style drawing interface

flush()Image[source]
render(op:str,xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,brush:Brush|Pen|None=None,**kwargs:Any)None[source]
settransform(offset:tuple[float,float])None[source]

Sets a transformation offset.

arc(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,start:float,end:float,*options:Any)None[source]

Draws an arc (a portion of a circle outline) between the start and endangles, inside the given bounding box.

chord(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,start:float,end:float,*options:Any)None[source]

Same asarc(), but connects the end pointswith a straight line.

ellipse(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,*options:Any)None[source]

Draws an ellipse inside the given bounding box.

line(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,*options:Any)None[source]

Draws a line between the coordinates in thexy list.

pieslice(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,start:float,end:float,*options:Any)None[source]

Same as arc, but also draws straight lines between the end points and thecenter of the bounding box.

polygon(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,*options:Any)None[source]

Draws a polygon.

The polygon outline consists of straight lines between the givencoordinates, plus a straight line between the last and the firstcoordinate.

rectangle(xy:Sequence[float]|Sequence[Sequence[float]],pen:Pen|Brush|None,*options:Any)None[source]

Draws a rectangle.

text(xy:tuple[float,float],text:AnyStr,font:Font)None[source]

Draws the string at the given position.

textbbox(xy:tuple[float,float],text:AnyStr,font:Font)tuple[float,float,float,float][source]

Returns bounding box (in pixels) of given text.

Returns:

(left,top,right,bottom) bounding box

textlength(text:AnyStr,font:Font)float[source]

Returns length (in pixels) of given text.This is the amount by which following text should be offset.

ImageMode module

classPIL.ImageMode.ModeDescriptor(mode:str,bands:tuple[str,...],basemode:str,basetype:str,typestr:str)[source]

Bases:NamedTuple

Wrapper for mode strings.

bands:tuple[str,...]

Alias for field number 1

basemode:str

Alias for field number 2

basetype:str

Alias for field number 3

mode:str

Alias for field number 0

typestr:str

Alias for field number 4

PIL.ImageMode.getmode(mode:str)ModeDescriptor[source]

Gets a mode descriptor for the given mode.

PaletteFile module

classPIL.PaletteFile.PaletteFile(fp:IO[bytes])[source]

Bases:object

File handler for Teragon-style palette files.

getpalette()tuple[bytes,str][source]
rawmode='RGB'

PcfFontFile module

classPIL.PcfFontFile.PcfFontFile(fp:BinaryIO,charset_encoding:str='iso8859-1')[source]

Bases:FontFile

Font file plugin for the X11 PCF format.

name='name'
PIL.PcfFontFile.sz(s:bytes,o:int)bytes[source]

PngImagePlugin.iTXt class

classPIL.PngImagePlugin.iTXt(text:str,lang:str|None=None,tkey:str|None=None)[source]

Bases:str

Subclass of string to allow iTXt chunks to look like strings whilekeeping their extra information

__new__(cls,text,lang,tkey)[source]
Parameters:
  • value – value for this key

  • lang – language code

  • tkey – UTF-8 version of the key name

lang:str|bytes|None
tkey:str|bytes|None

PngImagePlugin.PngInfo class

classPIL.PngImagePlugin.PngInfo[source]

Bases:object

PNG chunk container (for use with save(pnginfo=))

add(cid:bytes,data:bytes,after_idat:bool=False)None[source]

Appends an arbitrary chunk. Use with caution.

Parameters:
  • cid – a byte string, 4 bytes long.

  • data – a byte string of the encoded data

  • after_idat – for use with private chunks. Whether the chunkshould be written after IDAT

add_itxt(key:str|bytes,value:str|bytes,lang:str|bytes='',tkey:str|bytes='',zip:bool=False)None[source]

Appends an iTXt chunk.

Parameters:
  • key – latin-1 encodable text key name

  • value – value for this key

  • lang – language code

  • tkey – UTF-8 version of the key name

  • zip – compression flag

add_text(key:str|bytes,value:str|bytes|iTXt,zip:bool=False)None[source]

Appends a text chunk.

Parameters:
  • key – latin-1 encodable text key name

  • value – value for this key, text or anPIL.PngImagePlugin.iTXt instance

  • zip – compression flag

TarIO module

classPIL.TarIO.TarIO(tarfile:str,file:str)[source]

Bases:ContainerIO[bytes]

A file object that provides read access to a given member of a TAR file.

WalImageFile module

This reader is based on the specification available from:https://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtmland has been tested with a few sample files found using google.

Note

This format cannot be automatically recognized, so the readeris not registered for use withPIL.Image.open().To open a WAL file, use thePIL.WalImageFile.open() function instead.

classPIL.WalImageFile.WalImageFile(fp:StrOrBytesPath|IO[bytes],filename:str|bytes|None=None)[source]

Bases:ImageFile

format:str|None='WAL'
format_description:str|None='Quake2Texture'
load()Image.core.PixelAccess|None[source]

Load image data based on tile list

PIL.WalImageFile.open(filename:str|bytes|PathLike[str]|PathLike[bytes]|IO[bytes])WalImageFile[source]

Load texture from a Quake2 WAL texture file.

By default, a Quake2 standard palette is attached to the texture.To override the palette, use thePIL.Image.Image.putpalette() method.

Parameters:

filename – WAL file name, or an opened file handle.

Returns:

An image instance.

On this page

[8]ページ先頭

©2009-2025 Movatter.jp