PIL Image.imageオブジェクトをbase64文字列に変換する方法は?

ハマドクレシ:

base64でエンコードされた画像を90度回転するように操作しようとしています。この操作の後、base64文字列に変換し直したいと思います。しかし、残念ながらまだこれを達成することはできません。

これが私がこれまでに行ったことです:

image_string = StringIO(base64.b64decode(base64_string_here))
image = Image.open(image_string)
angle = 90
rotated_image = image.rotate( angle, expand=1 )

Kindyは、このrotate_imageをbase64文字列に変換する方法を教えてくれます。

次にdir()、rotated_image の例を示します。

['_Image__transformer'、 '__doc__'、 '__getattr__'、 '__init__'、 '__module__'、 '__repr__'、 '_copy'、 '_dump'、 '_expand'、 '_makeself'、 '_new'、 'category'、 ' convert、 'copy'、 'crop'、 'draft'、 'filter'、 'format'、 'format_description'、 'fromstring'、 'getbands'、 'getbbox'、 'getcolors'、 'getdata'、 'getextrema' 、「getim」、「getpalette」、「getpixel」、「getprojection」、「histogram」、「im」、「info」、「load」、「mode」、「offset」、「palette」、「paste」、「ポイント」、「putalpha」、「putdata」、「putpalette」、「putpixel」、「quantize」、「readonly」、 'resize'、 'rotate'、 'save'、 'seek'、 'show'、 'size'、 'split'、 'tell'、 'thumbnail'、 'tobitmap'、 'tostring'、 'transform'、 '転置」、「検証」]

user3255354:

Python 3

import base64
from io import BytesIO

buffered = BytesIO()
image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())

Python 2

import base64
import cStringIO

buffer = cStringIO.StringIO()
image.save(buffer, format="JPEG")
img_str = base64.b64encode(buffer.getvalue())

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

AndroidでImageオブジェクトをBase64文字列に変換する

分類Dev

wand.image.ImageをPIL.Imageに変換する方法は?

分類Dev

PILとpygame.image

分類Dev

PIL image _crop to tensor、in tensorflow

分類Dev

PIL : PNG image as watermark for a JPG image

分類Dev

Getting pixels from an image using PIL

分類Dev

Make blur all around a rectangle in image with PIL

分類Dev

Convert PIL Image to Bytes, getting Error

分類Dev

python PIL show image - file system error

分類Dev

PIL image shows OK but saves black

分類Dev

numpy配列に変換したときにPIL.Image.open()関数オブジェクトの次元が変更される理由

分類Dev

PIL.Image.Image画像の配置方法QPushButton(PyQt)

分類Dev

convert float image array to int in PIL via Image.fromarray

分類Dev

jpeg文字列をPILイメージオブジェクトに変換する

分類Dev

ScalaFX:Imageオブジェクトをバイト配列に変換する方法

分類Dev

How to send an PIL Image via telegram bot without saving it to a file

分類Dev

How to convert 2D matrix of RGBA tuples into PIL Image?

分類Dev

PIL Image.size returns the opposite width/height

分類Dev

PIL image.convert( "RGB")は画像をsRGBまたはAdobeRGBに変換しますか?

分類Dev

imageView.imageをTiBlobオブジェクトに変換する方法は?

分類Dev

JSONオブジェクトをbase64文字列に変換する方法は?

分類Dev

PIL `Image.fromarray`を使用して画像を作成すると、AttributeErrorが発生します: 'list'オブジェクトに属性がありません '__array_interface__'

分類Dev

オブジェクトにテクスチャをロードするときのPyOpenGLとPIL.Imageの色分解効果

分類Dev

PIL.ImageとPIL.Image.Imageの混同と、それらの正しい使用方法は?

分類Dev

PIL / Imageを使用して.tifスタックを保存する

分類Dev

PILイメージをbase64に変換するより高速な方法

分類Dev

Paste an image to another image at two given co-ordinates with altered opacity using PIL or OpenCV in Python

分類Dev

`PIL.Image.frombytes`に指定するサイズ

分類Dev

PIL Image.sizeは、反対の幅/高さを返します

Related 関連記事

  1. 1

    AndroidでImageオブジェクトをBase64文字列に変換する

  2. 2

    wand.image.ImageをPIL.Imageに変換する方法は?

  3. 3

    PILとpygame.image

  4. 4

    PIL image _crop to tensor、in tensorflow

  5. 5

    PIL : PNG image as watermark for a JPG image

  6. 6

    Getting pixels from an image using PIL

  7. 7

    Make blur all around a rectangle in image with PIL

  8. 8

    Convert PIL Image to Bytes, getting Error

  9. 9

    python PIL show image - file system error

  10. 10

    PIL image shows OK but saves black

  11. 11

    numpy配列に変換したときにPIL.Image.open()関数オブジェクトの次元が変更される理由

  12. 12

    PIL.Image.Image画像の配置方法QPushButton(PyQt)

  13. 13

    convert float image array to int in PIL via Image.fromarray

  14. 14

    jpeg文字列をPILイメージオブジェクトに変換する

  15. 15

    ScalaFX:Imageオブジェクトをバイト配列に変換する方法

  16. 16

    How to send an PIL Image via telegram bot without saving it to a file

  17. 17

    How to convert 2D matrix of RGBA tuples into PIL Image?

  18. 18

    PIL Image.size returns the opposite width/height

  19. 19

    PIL image.convert( "RGB")は画像をsRGBまたはAdobeRGBに変換しますか?

  20. 20

    imageView.imageをTiBlobオブジェクトに変換する方法は?

  21. 21

    JSONオブジェクトをbase64文字列に変換する方法は?

  22. 22

    PIL `Image.fromarray`を使用して画像を作成すると、AttributeErrorが発生します: 'list'オブジェクトに属性がありません '__array_interface__'

  23. 23

    オブジェクトにテクスチャをロードするときのPyOpenGLとPIL.Imageの色分解効果

  24. 24

    PIL.ImageとPIL.Image.Imageの混同と、それらの正しい使用方法は?

  25. 25

    PIL / Imageを使用して.tifスタックを保存する

  26. 26

    PILイメージをbase64に変換するより高速な方法

  27. 27

    Paste an image to another image at two given co-ordinates with altered opacity using PIL or OpenCV in Python

  28. 28

    `PIL.Image.frombytes`に指定するサイズ

  29. 29

    PIL Image.sizeは、反対の幅/高さを返します

ホットタグ

アーカイブ