Pydroid PIL在安卓上无法显示图像。

huangapple go评论78阅读模式
英文:

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 Pydroid PIL在安卓上无法显示图像。

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 Pydroid PIL在安卓上无法显示图像。

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上是IMageMagickdisplayeogxv,在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()

huangapple
  • 本文由 发表于 2023年2月13日 23:26:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75437910.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定