Skip to content

Getting URL image #6960

Feb 21, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi. I don't understand your question.

  1. Are you asking how to reread text after you have written it to an image? In other words, OCR? Pillow doesn't offer that functionality. Perhaps try another Python library, like https://pypi.org/project/pytesseract/
  2. Are you asking how to encode your image using base64, so that it can then be part of a background-image CSS property?
import base64
with open("im.png", "rb") as fp:
    data = base64.b64encode(fp.read())
    print(b"background-image: url(data:image/gif;base64,"+data+b")")

You mentioned that you wanted to write on the image first though.

import base64
from io import BytesIO
from PIL import Image, ImageDraw, ImageFont
im = Image.new("RGB", (290

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@radarhere
Comment options

Answer selected by radarhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants