I'm running into a weird issue using the Python Imaging Library. Here's the exact code I used for reproducibility (in ipython
) with the version at the end to help clarify:
Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 11:58:13)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from PIL import (Image, ImageDraw)
In [2]: def title_text(height):
...: im = Image.new(mode='L', size=(516,height), color=255)
...: draw = ImageDraw.Draw(im)
...: draw.text((0,0), "Title Text")
...: im.save("test_"+str(height)+".png")
...:
In [3]: title_text(100)
In [4]: title_text(50000)
In [5]: import PIL
In [6]: PIL.__version__
Out[6]: '4.1.1'
The output I get is extremely odd. For the first image, I've attached it here:
You can see that "Title Text" successfully gets displayed here.
But when I do the same thing for the image with a height of 50k pixels, for some reason the title text is nowhere to be seen. The image is just plain white everywhere; I can't see text despite scrolling up to the top and zooming in. I used to be able to get much larger images (with height far greater than 50k pixels) with stuff pasted on them, but this doesn't seem to work.
(1) Can anyone reproduce this result? and (2) Any ideas on why this might not work?
It's probably your viewer. If I open test_50000.png
in Chrome and magnify it to 500% I see the tiny text at the top.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.