- 安装
- 关于 Pillow
- 指南
- API参考
- Image Module
- ImageChops (“Channel Operations”) Module
- ImageColor Module
- ImageDraw Module
- ImageEnhance Module
- ImageFile Module
- ImageFilter Module
- ImageFont Module
- ImageGrab Module (Windows-only)
- ImageMath Module
- ImageOps Module
- ImagePalecodee Module
- ImagePath Module
- ImageQt Module
- ImageSequence Module
- ImageStat Module
- ImageTk Module
- ImageWin Module (Windows-only)
- PSDraw Module
- PIL Package (autodoc of remaining modules)
- 附录
- PIL 原始帮助文档
ImageTk Module
The ImageTk
module contains support to create and modify Tkinter BitmapImage and PhotoImage objects from PIL images.
For examples, see the demo programs in the Scripts directory.
- class
PIL.ImageTk.
BitmapImage
(image=None, **kw) A Tkinter-compatible bitmap image. This can be used everywhere Tkinter expects an image object.
The given image must have mode “1”. Pixels having value 0 are treated as transparent. Options, if any, are passed on to Tkinter. The most commonly used option is foreground, which is used to specify the color for the non-transparent parts. See the Tkinter documentation for information on how to specify colours.
参数: image – A PIL image. height
()Get the height of the image.
返回: The height, in pixels.
width
()Get the width of the image.
返回: The width, in pixels.
- class
PIL.ImageTk.
PhotoImage
(image=None, size=None, **kw) A Tkinter-compatible photo image. This can be used everywhere Tkinter expects an image object. If the image is an RGBA image, pixels having alpha 0 are treated as transparent.
The constructor takes either a PIL image, or a mode and a size. Alternatively, you can use the file or data options to initialize the photo image object.
参数: - image – Either a PIL image, or a mode string. If a mode string is used, a size must also be given.
- size – If the first argument is a mode string, this defines the size of the image.
- file – A filename to load the image from (using
Image.open(file)
). - data – An 8-bit string containing image data (as loaded from an image file).
height
()Get the height of the image.
返回: The height, in pixels.
paste
(im, box=None)Paste a PIL image into the photo image. Note that this can be very slow if the photo image is displayed.
参数: - im – A PIL image. The size must match the target region. If the mode does not match, the image is converted to the mode of the bitmap image.
- box – A 4-tuple defining the left, upper, right, and lower pixel coordinate. If None is given instead of a tuple, all of the image is assumed.
width
()Get the width of the image.
返回: The width, in pixels.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论