Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59483
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <spk265@nyu.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.031 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'string': 0.09; 'pil': 0.09; 'pixel': 0.09; 'cc:addr:python-list': 0.11; 'file-like': 0.16; 'finney': 0.16; 'latter,': 0.16; 'metadata.': 0.16; 'mode,': 0.16; 'perfect.': 0.16; 'subject:Converting': 0.16; 'subject:image': 0.16; 'wrote:': 0.18; 'library': 0.18; 'thu,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'bytes': 0.24; 'specify': 0.24; 'string,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'shown': 0.26; 'header :In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'usually': 0.31; 'extract': 0.31; 'writes:': 0.31; 'allows': 0.31; 'class': 0.32; 'front': 0.32; 'received:209.85.212': 0.32; 'url:python': 0.33; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'subject:data': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'wrong': 0.37; 'turn': 0.37; 'received:209': 0.37; 'skip:& 10': 0.38; 'thank': 0.38; 'ben': 0.38; 'nov': 0.38; 'url:library': 0.38; 'pm,': 0.38; 'skip:p 20': 0.39; 'url:mail': 0.40; 'read': 0.60; 'new': 0.61; 'url:3': 0.61; '8bit%:10': 0.64; 'charset:windows-1252': 0.65; 'reads': 0.68; '4:29': 0.84; 'skip:\x91 10': 0.84; 'usage.': 0.84; 'whereas': 0.91; '2013': 0.98 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=yEX6owZYDhxVpe3r6czRmfso9hG/qpuZ4Ts2x1LijMI=; b=Op36nuMpIhnF9CNkbVioHxSDCRsVi2Deayz6kuKJM1BJ13JwNobmK9d/5XZIxPqEDO R7zdYNfQCVmSiH2WBgMJbkjb6xkIw8NedUXQZXfdH6dZ3Lnp5wsJsN6xW3HP77k0ffmz 08JP1IRbJLzQu7FSRGUbDVsdUI+MDNmLu+Lr6NeCtySLvQEt5g/OArw7rYCjn05ejGud ZUSB8R87y6RQIJ5AjZOtG0eTojkOdxqaMDfnvlqsNqDZ/QObjyl4toVkNJPMsv0nfGi6 GNXDy1iP56n9/uiRYBb6U57rF4oqEv50AvcrHYNlDHCBJsMHJElEOlcpQKWZ7/NM7Oiw 8tJQ== |
| X-Gm-Message-State | ALoCoQnHOhIeyDO2jwfLCL7pmdxlQG14cI24I60K7W1xLwWhrS1OUMvckxbsRwVk2wWrVORtgZsc |
| MIME-Version | 1.0 |
| X-Received | by 10.52.185.8 with SMTP id ey8mr181342vdc.107.1384467778165; Thu, 14 Nov 2013 14:22:58 -0800 (PST) |
| In-Reply-To | <7w1u2iwu3l.fsf@benfinney.id.au> |
| References | <CALVX-oYZzX8CEvP58=mfyk2yYXFRkk4e0t66bFn8na-h_BNpHw@mail.gmail.com> <7w61ruwv0q.fsf@benfinney.id.au> <7w1u2iwu3l.fsf@benfinney.id.au> |
| Date | Thu, 14 Nov 2013 17:22:58 -0500 |
| Subject | Re: Converting hex data to image |
| From | Shyam Parimal Katti <spk265@nyu.edu> |
| To | Ben Finney <ben+python@benfinney.id.au> |
| Content-Type | multipart/alternative; boundary=bcaec54866e21eeea104eb2a8605 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2627.1384467786.18130.python-list@python.org> (permalink) |
| Lines | 109 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1384467787 news.xs4all.nl 16008 [2001:888:2000:d::a6]:44900 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:59483 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Perfect. Thank you @Ben and @Tim On Thu, Nov 14, 2013 at 4:29 PM, Ben Finney <ben+python@benfinney.id.au>wrote: > Ben Finney <ben+python@benfinney.id.au> writes: > > > To turn a byte string into a file-like object for use with PIL, extract > > the byte string as ‘image_data’, use the standard library ‘io.StringIO’ > > class <URL:http://docs.python.org/3/library/io.html#io.StringIO>, then > > create a new ‘PIL.Image’ object by reading from that pseudo-file:: > > My apologies, I showed the wrong usage. This should work:: > > import io > > import PIL > > photo_data = # … get the byte string from wherever it is … > photo_infile = io.StringIO(photo_data) > photo_image = PIL.Image.open(photo_infile) > > That is, ‘PIL.Image.frombytes’ allows you to read the bytes from a byte > string, but requires you to also specify metadata about the image data > (format, pixel mode, size), whereas ‘PIL.Image.open’ reads the data from > a file-like object and parses all the metadata. So you usually want to > use the latter, as shown here. > > -- > \ “People's Front To Reunite Gondwanaland: Stop the Laurasian | > `\ Separatist Movement!” —wiredog, http://kuro5hin.org/ | > _o__) | > Ben Finney > > -- > https://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Converting hex data to image Shyam Parimal Katti <spk265@nyu.edu> - 2013-11-14 17:22 -0500
csiph-web