473,216 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

PIL Decoder mode vs raw mode arguemts

Hey everyone,

I am currently creating images pixel by pixel. This is too slow for many images. Anyways, I want to use the fromstring module in the Image library. I have read at this url, http://effbot.org/imagingbook/decoder.htm, that I use an unsigned little endian 16 bit decoder in the calling of the function.

My segment that is called looks like this:

img2=Image.fromstring("L",(512,512),dummystring2," raw", "F;16")

However I run into some type of library issue that I have yet to solve.

Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
img2=Image.fromstring("L",(512,512),dummystring2," raw", "F;16")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1744, in fromstring
im.fromstring(data, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 570, in fromstring
d = _getdecoder(self.mode, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 373, in _getdecoder
return apply(decoder, (mode,) + args + extra)
ValueError: unknown raw mode

Am I supposed to import some decoder library, and if so, which one?

Thanks alot,
JP
Oct 1 '07 #1
6 8722
bartonc
6,596 Expert 4TB
My apologies, Nebulism. I just found your post in the Articles section.
Oct 2 '07 #2
bartonc
6,596 Expert 4TB
I'll check the Python Imaging Library Handbook and get back to you.
Oct 2 '07 #3
bartonc
6,596 Expert 4TB
Hey everyone,

I am currently creating images pixel by pixel. This is too slow for many images. Anyways, I want to use the fromstring module in the Image library. I have read at this url, http://effbot.org/imagingbook/decoder.htm, that I use an unsigned little endian 16 bit decoder in the calling of the function.

My segment that is called looks like this:

img2=Image.fromstring("L",(512,512),dummystring2," raw", "F;16")

However I run into some type of library issue that I have yet to solve.

Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
img2=Image.fromstring("L",(512,512),dummystring2," raw", "F;16")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1744, in fromstring
im.fromstring(data, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 570, in fromstring
d = _getdecoder(self.mode, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 373, in _getdecoder
return apply(decoder, (mode,) + args + extra)
ValueError: unknown raw mode

Am I supposed to import some decoder library, and if so, which one?

Thanks alot,
JP
This page, in the section entitled "Decoding Floating Point Data" says:
You can use the "raw" decoder to read images where data is packed in any standard machine data type, using one of the following raw modes:
mode description
"F" 32-bit native floating point.
"F;8" 8-bit unsigned integer.
"F;8S" 8-bit signed integer.
"F;16" 16-bit little endian unsigned integer.
"F;16S" 16-bit little endian signed integer.
"F;16B" 16-bit big endian unsigned integer.
"F;16BS" 16-bit big endian signed integer.
"F;16N" 16-bit native unsigned integer.
"F;16NS" 16-bit native signed integer.
Oct 2 '07 #4
I have been looking at that and if you notice the function that I call includes the little endian floating point 16 bit int "F;16". Some reason it does not recognize the decoder (look at the error text included in the original post)? I was wondering if it was a syntax issue. Any ideas?

JP
Oct 2 '07 #5
bartonc
6,596 Expert 4TB
I have been looking at that and if you notice the function that I call includes the little endian floating point 16 bit int "F;16". Some reason it does not recognize the decoder (look at the error text included in the original post)? I was wondering if it was a syntax issue. Any ideas?

JP
Reading this:
The raw mode field is used to determine how the data should be unpacked to match PIL's internal pixel layout. PIL supports a large set of raw modes; for a complete list, see the table in the Unpack.c module. The following table describes some commonly used raw modes:
mode description
"1" 1-bit bilevel, stored with the leftmost pixel in the most significant bit. 0 means black, 1 means white.
"1;I" 1-bit inverted bilevel, stored with the leftmost pixel in the most significant bit. 0 means white, 1 means black.
"1;R" 1-bit reversed bilevel, stored with the leftmost pixel in the least significant bit. 0 means black, 1 means white.
"L" 8-bit greyscale. 0 means black, 255 means white.
I get the impression that you have mode and raw mode arguments reversed.

Try
Expand|Select|Wrap|Line Numbers
  1. img2 = Image.fromstring("F;16", (512, 512), dummystring2, "raw", "L")
Oct 2 '07 #6
I have tried reorganizing the inputs to the function, however it is still failing.

Is there a specific library i might need to use?

img2=Image.fromstring("L",(512,512), buffed, "raw", "F;16")

Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
img2=Image.fromstring("L",(512,512), buffed, "raw", "F;16")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1744, in fromstring
im.fromstring(data, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 570, in fromstring
d = _getdecoder(self.mode, decoder_name, args)
File "C:\Python25\lib\site-packages\PIL\Image.py", line 373, in _getdecoder
return apply(decoder, (mode,) + args + extra)
ValueError: unknown raw mode



Thanks,
JP
Oct 2 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: S Etchelecu | last post by:
I'm having trouble understanding the MIME::Decoder usage. Within the context of a MIME email handling program I have an array, @data, and I want to uuencode it. I thought I could instantiate a...
2
by: Geru | last post by:
Hi there!, I'm looking for a Perl Module that does email decoder. I mean something that I put the email file and the Module returns the Message, Subject, Headers, etc, etc. And it should work...
0
by: Whitney | last post by:
I'm not sure which category this would fall under, but I assumed that something dealing with languages would be as good a place as any. I was sent a message using characters such as Z|" (which...
8
by: jbrewer | last post by:
I'm trying to read in a FITs image file for my research, and I decided that writing a file decoder for the Python imaging library would be the easiest way to accomplish this for my needs. FITs is...
3
by: Peter | last post by:
I have a problem which seems to come up from time to time but I can't find anything relevant in the archives. I have used PIL v1.1.5 with no problem on Windows for some time but now wish to put it...
0
by: jordi_ramis | last post by:
Hi, I'm looking for a FREE jpeg decoder class or component that lets me: - Load the jpeg from a stream (file). - As an option not to load ALL the jpeg, only the necessary part to make a...
6
by: Doug Stell | last post by:
Can anyone provide guidance on building an ASN.1 decoder and encoder in Python? This does not have to be a general purpose implementation, drivenf from an ASN.1 template. It can be dedicated hard...
1
by: =?Utf-8?B?c2Fz?= | last post by:
when i try to put my tv on media center it displays a message saying video decoder is currently in use by another application what does it mean -- sas
6
by: Ankit | last post by:
Hi everyone,i wanted to build a flash decoder using python can somebody tell me which library to use and what steps should i follow to make a flash(video) decoder?By a decoder i mean that i need to...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.