Any example to display jpegPhoto?

Michael Ströder michael at stroeder.com
Sat Jun 6 12:35:18 CEST 2009


Zhang Huangbin wrote:
> Michael Ströder wrote:
>> Zhang Huangbin wrote:
>>   
>>> Is there ny example to display jpegPhoto stored in LDAP as base64 format?
>>>     
>> Not sure what you really want to display and where.
>>
>> How about entry['jpegPhoto'][0].encode('base64') ?
>>
>> Or are you talking about LDIF? Then use module ldif which automagically
>> base64-encodes NON-ASCII values.
> 
> Just display the jpegPhoto on web page, not LDIF. :)
> 
> I got encoded string after 'entry['jpegPhoto'][0].encode('base64') ',
> but how to convert it to a image file and use '<img> tag in HTML to
> display it?

entry['jpegPhoto'][0] is the raw binary JPEG data. You can send this
directly to the browser in the body of a HTTP response with MIME-type
image/jpeg. This is kind of off-topic here since it's rather related to
web app programming. So I'd recommend to ask in the forum related to the
web app framework you're using.

Ciao, Michael.



More information about the python-ldap mailing list