Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
1)
<img src="data:image/jpeg;base64,/9j/4RiDRXhpZgAATU0AKgA...">

2)
<img src="http://tracuunnt.gdt.gov.vn/tcnnt/captcha.png?uid=d847715b-a146-4383-ae85-ce8fd895492d">


I'm curious. Number 1) is a base64 image and can both be encoded and decoded as seen in many examples. Meanwhile, the use of number 2) doesn't seem to be popular and I don't know if it's external image can be decoded or read.

What I have tried:

I tried to decode with
base64.b64decode()
then
IO.BytesIO()
before passing the object to
PIL.Image.open()
but I got
OSError: cannot identify image file <_io.BytesIO object at 0x08FA09F0>
Posted
Updated 22-Feb-21 4:37am

1 solution

Images are a pain: they have been used for tracking purposes (mostly to identify "active" email addresses) so many systems (including nearly all email readers) do not download them when found as a URL link.

Base64 images on the other hand are embedded into the HTML stream that is transferred and as such are "safe" - that doesn't mean that it's readable by all systems, particularly if it isn't the latest version.

I'd start by converting the Base64 data to binary, and saving it as an image file - then using the OS to look at that and see if it contains valid image data. If it does, then try opening that file in your app to see if it works.

That should at least give you an idea where the problem may be!

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900