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.from string("L",(512 ,512),dummystri ng2,"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#4 1>", line 1, in <module>
img2=Image.from string("L",(512 ,512),dummystri ng2,"raw", "F;16")
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 1744, in fromstring
im.fromstring(d ata, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 570, in fromstring
d = _getdecoder(sel f.mode, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.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
6 8785 bartonc 6,596
Recognized Expert Expert
My apologies, Nebulism. I just found your post in the Articles section.
bartonc 6,596
Recognized Expert Expert
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.from string("L",(512 ,512),dummystri ng2,"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#4 1>", line 1, in <module>
img2=Image.from string("L",(512 ,512),dummystri ng2,"raw", "F;16")
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 1744, in fromstring
im.fromstring(d ata, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 570, in fromstring
d = _getdecoder(sel f.mode, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.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.
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
bartonc 6,596
Recognized Expert Expert
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 - img2 = Image.fromstring("F;16", (512, 512), dummystring2, "raw", "L")
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.from string("L",(512 ,512), buffed, "raw", "F;16")
Traceback (most recent call last):
File "<pyshell#2 6>", line 1, in <module>
img2=Image.from string("L",(512 ,512), buffed, "raw", "F;16")
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 1744, in fromstring
im.fromstring(d ata, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 570, in fromstring
d = _getdecoder(sel f.mode, decoder_name, args)
File "C:\Python25\li b\site-packages\PIL\Im age.py", line 373, in _getdecoder
return apply(decoder, (mode,) + args + extra)
ValueError: unknown raw mode
Thanks,
JP
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 MIME::Decoder
with an encoding of 'x-uuencode' and then call the encode method as,
my $decoder = new MIME::Decoder('x-uuencode');
$decoder->encode(@data, @uudata);
However, the encode method only accepts STREAMs as arguments. Obviously I
|
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 with any email coming from every single email
client, I mean for any kind of email.
Thanks.
Gerardo.
|
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 of course is Alt+numbers),
and I've heard these characters called Windows Character
Set, but I don't know the "official" name for them (which
would be much appreciated if anyone did know). There is
supposedly a decoder that will allow me to...
|
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 a raw data format
used in astronomy.
Anyway, I followed the example in the PIL documentation online, and I
also had a look at the FITs image stub file included with PIL 1.1.5. I
cooked up something that should work (or nearly work), but I keep...
|
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 on Linux (Suse
Linux v10.0). I obtained and built the JPEG libraries (jpeg-6b) without
any problem. The tests for the installation work fine. I built Python
2.4.2 from the sources but with no special options, just 'out of the
box'. This works...
| |
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 thumbnail. This is, a faster way to generate thumbnails.
Do you know some free class, component or piece of code that I can
|
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 coded to a
particular template.
Doug Stell, celiadoug@mchsi.com
|
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
|
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
display all the pixel values of each frame.Waiting for your replies.
Regards
Ankit Anand
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |