英文:
Pydroid PIL does not display image on android
问题
I am writing code on my Android. I know, it's weird. But my notebook is being repaired
I am trying to display an image generated by the pillow library. I'm doing this within the Pydroid app.
Matplotlib charts are displaying okay. But not the image of pillow.
There is a question similar to mine, that links this problem to ImageMagick not being installed. But it is not particular to Android. If this is also the case for me, please specify how to install it, since it is not a pip package. Here is my code
from PIL import Image
img = Image.new(
mode='RGB',
size=(400, 240),
color=(153, 153, 153)
)
img.show()
英文:
I am writing code on my Android. I know, it's weird. But my notebook is being repaired
I am trying to display an image generated by pillow library. I'm doing this within Pydroid app.
Matplotlib charts are displaying okay. But not the image of pillow.
There is a question similar to mine, that links this problem to image magic not being installed. But it is not particular to Android. If this is also the case for me, please specify how to install it, since it is not a pip package. Here is my code
from PIL import Image
img = Image.new(
mode='RGB',
size=(400, 240),
color=(153,153,153)
)
img.show()
答案1
得分: 1
The PIL.Image.show()
方法实际上只是一个快速的调试工具,它使用你的操作系统内置的图像查看器(在Linux上是IMageMagick的display
、eog
或xv
,在macOS上是Preview
)来快速查看PIL图像。我认为没有人预期它会在Android上使用。
我对Android不太熟悉,但如果你知道该平台上的图像查看器,也许可以像这样集成它。
如果不行,因为它只是一个快速的调试工具,而Matplotlib可行,你可以使用它来显示你的PIL图像:
from PIL import Image
import matplotlib.pyplot as plt
# 创建一个PIL图像
img = Image.new('RGB', (400, 240), color=(255, 0, 0))
# 用Matplotlib显示
plt.imshow(img)
plt.axis('off')
plt.show()
英文:
The PIL.IMage.show()
method is really just a quick debugging tool that uses your OS's built-in image viewer (IMageMagick display
, eog
or xv
on Linux, Preview
on macOS) to quickly view a PIL Image. I don't think anyone anticipated its use on Android.
I am unfamiliar with Android, but if you know of an image viewer for that platform you can maybe integrate it like this.
If not, as it's just a quick debugging tool, and as Matplotlib works, you can use that to display your PIL Images:
from PIL import Image
import matplotlib.pyplot as plt
# Create a PIL Image
img = Image.new('RGB', (400, 240), color=(255,0,0))
# Display with Matplotlib
plt.imshow(img)
plt.axis('off')
plt.show()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论