Working with unsigned/signed types

brian at brianshirk.com brian at brianshirk.com
Wed Dec 20 00:36:01 EST 2006


Hi everyone-

I've been away from coding for a while (I turned into a professional

photographer)...  

So now I've taken up a project involving working with EXIF and XMP metadata in

image files (mainly JPEG and TIFF), and am having some trouble figuring out how

to handle some of the data...



Here's what I'm having to do:

Inside the files, there are various types of data which can be split apart and

organized fairly easily, given you have unsigned and signed types...  Which is

where I'm running into problems remembering how everything works.



The first part of the question is fairly basic - in C, working with signed

integers, the MSB (is that still the right term?) is used to denote positive and

negative, and the following bits increase towards positive infinity, correct? 

Such that in C, adding one to 0x7fffffff would cause the number to go around to

-0x7fffffff (or whatever that is), giving -1 for 0xffffffff?



Secondly, (and this is my weak point as a programmer) to re-insert the data

after, what would be the most efficient way to pull everything back apart into

individual characters for putting it all back into the files?  I could probably

figure out something that would work, but I wouldn't be so sure as to its

reliability.



Third, being a photographer now rather than a coder, I'd like to give back the

modules I'm writing to the community (it looks like very little of the sort

exists), but would rather not worry about them in the future...  Is there a good

way to go about this?



Thanks!

-Brian Shirk



Avalanche Photography LLC

www.AvalanchePhoto.com

McCall, Idaho




More information about the Python-list mailing list