invalid picture on Windows

Hi all, especially Greg.

I'm currently working on a Python version of falsecolor. The script
uses pcomb, psign and pcompos just like the original falsecolor
script. As always it works fine on Mac/Unix but Windows need further
care:

The images I get look all right to me but when I try to open them in
ximage (or the Windows equivalent) I get the message that the image is
not a valid file format. It seems to be related to the resolution
string. However that is present and the image basically is created by
pcompos.

My wild guess is that the information in the head with all it's back
slashes and quoting interferes with the format of the image file. If
that was the case I could remove the offending lines if I could
identify them.

It's also entirely possible that the binary data of the image gets
messed up in the last step. I tried to keep the default output to
stdout, so I have to read the image data from the pcompos and write it
to stdout. That works on Unix but I'm not sure about Windows.

You can find 2 sample picture files as "attachments" at the end of this site:

"fc_mac.hdr" was created on a Mac, "fc_win.hdr" on Windows. The images
have no relation to the web-site, but it's the easiest way for me to
upload these two tiny files.

I hope someone can make sense out of this.

Regards,
Thomas

Hi Thomas,

I had a quick look at your output, and it appears that the header is being written with '\r\n' at the end of each line rather than the expected '\n' alone. This causes problems especially for the resolution string. The pcompos program (and most others in Radiance) set binary mode before writing any output. Somehow, your script is bypassing this step, but I didn't have a look at it and don't know Python, anyway, so probably couldn't be much help.

-Greg

···

From: Thomas Bleicher <[email protected]>
Date: March 29, 2010 5:25:14 AM CDT

Hi all, especially Greg.

I'm currently working on a Python version of falsecolor. The script
uses pcomb, psign and pcompos just like the original falsecolor
script. As always it works fine on Mac/Unix but Windows need further
care:

The images I get look all right to me but when I try to open them in
ximage (or the Windows equivalent) I get the message that the image is
not a valid file format. It seems to be related to the resolution
string. However that is present and the image basically is created by
pcompos.

My wild guess is that the information in the head with all it's back
slashes and quoting interferes with the format of the image file. If
that was the case I could remove the offending lines if I could
identify them.

It's also entirely possible that the binary data of the image gets
messed up in the last step. I tried to keep the default output to
stdout, so I have to read the image data from the pcompos and write it
to stdout. That works on Unix but I'm not sure about Windows.

You can find 2 sample picture files as "attachments" at the end of this site:

http://sites.google.com/site/tbleicher/radiance/falsecolor2

"fc_mac.hdr" was created on a Mac, "fc_win.hdr" on Windows. The images
have no relation to the web-site, but it's the easiest way for me to
upload these two tiny files.

I hope someone can make sense out of this.

Regards,
Thomas

Thanks Greg.

I made a few more tests and it turns out that the same image data
written directly to a file works fine. The problem is apparently
introduced when I write to stdout.

The '\r\n' vs '\n' makes sense because that's where Python insists on
taking control and doing the right thing for the platform. I have to
figure out how to stop that.

Thanks,
Thomas

···

On Mon, Mar 29, 2010 at 3:16 PM, Gregory J. Ward <[email protected]> wrote:

Hi Thomas,

I had a quick look at your output, and it appears that the header is being
written with '\r\n' at the end of each line rather than the expected '\n'
alone. This causes problems especially for the resolution string. The
pcompos program (and most others in Radiance) set binary mode before writing
any output. Somehow, your script is bypassing this step, but I didn't have
a look at it and don't know Python, anyway, so probably couldn't be much
help.

-Greg

From: Thomas Bleicher <[email protected]>
Date: March 29, 2010 5:25:14 AM CDT

Hi all, especially Greg.

I'm currently working on a Python version of falsecolor. The script
uses pcomb, psign and pcompos just like the original falsecolor
script. As always it works fine on Mac/Unix but Windows need further
care:

The images I get look all right to me but when I try to open them in
ximage (or the Windows equivalent) I get the message that the image is
not a valid file format. It seems to be related to the resolution
string. However that is present and the image basically is created by
pcompos.

My wild guess is that the information in the head with all it's back
slashes and quoting interferes with the format of the image file. If
that was the case I could remove the offending lines if I could
identify them.

It's also entirely possible that the binary data of the image gets
messed up in the last step. I tried to keep the default output to
stdout, so I have to read the image data from the pcompos and write it
to stdout. That works on Unix but I'm not sure about Windows.

You can find 2 sample picture files as "attachments" at the end of this
site:

http://sites.google.com/site/tbleicher/radiance/falsecolor2

"fc_mac.hdr" was created on a Mac, "fc_win.hdr" on Windows. The images
have no relation to the web-site, but it's the easiest way for me to
upload these two tiny files.

I hope someone can make sense out of this.

Regards,
Thomas

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev