mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-26 23:24:45 +03:00
Add new_mode function
Currently `new` function creates a grayscale image in stack, it will break `paste` a colorful(i.e. `RGBA`) image. Repro Steps ``` pildriver.py save new.png paste open test1.png 0 200 paste open test2.png 0 0 new 400 400 0 ``` We will get a **grayscale** new.png rather than a **RGBA** one. This commit is to fix this by adding a new `new_mode` function. ``` pildriver.py save new.png paste open test1.png 0 200 paste open test2.png 0 0 new2 RGBA 400 400 0 ```
This commit is contained in:
parent
da2ea4cfe3
commit
d7d7e63e01
|
@ -122,6 +122,17 @@ class PILDriver(object):
|
|||
color = int(self.do_pop())
|
||||
self.push(Image.new("L", (xsize, ysize), color))
|
||||
|
||||
def do_new2(self):
|
||||
"""usage: new2 <string:mode> <int:xsize> <int:ysize> <int:color>:
|
||||
|
||||
Create and push a image of given mode, size and color.
|
||||
"""
|
||||
mode = int(self.do_pop())
|
||||
xsize = int(self.do_pop())
|
||||
ysize = int(self.do_pop())
|
||||
color = int(self.do_pop())
|
||||
self.push(Image.new(mode, (xsize, ysize), color))
|
||||
|
||||
def do_open(self):
|
||||
"""usage: open <string:filename>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user