Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59452 > unrolled thread

Re: Converting hex data to image

Started byTim Golden <mail@timgolden.me.uk>
First post2013-11-14 16:18 +0000
Last post2013-11-14 16:18 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Converting hex data to image Tim Golden <mail@timgolden.me.uk> - 2013-11-14 16:18 +0000

#59452 — Re: Converting hex data to image

FromTim Golden <mail@timgolden.me.uk>
Date2013-11-14 16:18 +0000
SubjectRe: Converting hex data to image
Message-ID<mailman.2608.1384445921.18130.python-list@python.org>
On 14/11/2013 15:32, Shyam Parimal Katti wrote:
> I am implementing an authentication system(in Django) using LDAP as the
> backend(django-auth-ldap). When we fetch the data from the LDAP server
> for a particular valid user, the data associated with the user contains
> the thumbnail photo in hex representation. E.x.:
> 
> [('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com',
> {'msExchBlockedSendersHash': ['\xce'], 'mailNickname': ['test_user'],
> 'primaryGroupID': ['513'], 'logonCount': ['1021'], *thumbnailPhoto:
> ['\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.....']*
> ...... ]
> 
> How do I convert the hex data for an image to the actual image?

Well, the first few bytes suggest that it's a JPEG, so save the bytes as
"something.jpg" and there you have it: an actual image.

Alternatively, you could load it into PIL [1] / Pillow [2] and
manipulate it as you see fit...

TJG

[1] http://www.pythonware.com/products/pil/
[2] https://pypi.python.org/pypi/Pillow/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web