473,386 Members | 1,720 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,386 software developers and data experts.

Rational numbers in exif info.

I'm not sure whether I am approaching this correctly?

I'm trying to get the focal length from exif info stored in an image.

The Visual studio help says it is stored in "An array of two Byte objects
that represent a rational number".
Yet there are eight bytes in the info? shown below.

89 00 00 00 0A 00 00 00

Are these supposed to be 2 byte or 4 byte objects, or am I completely
misunderstanding this rational number gizmo?
Both these if statements below retrieve the correct focal length 13.7 that I
expect, I'm just not sure if I am approaching the problem correctly in
either case?
if(propertyItem.Id == 0x920A)
{
int a = BitConverter.ToInt32(propItems[count].Value,0);
int b = BitConverter.ToInt32(propItems[count].Value,4);
double focalLength = (double)a/b;
}
if(propertyItem.Id == 0x920A)
{
short a = BitConverter.ToInt16(propItems[count].Value,0);
short b = BitConverter.ToInt16(propItems[count].Value,4);
double focalLength = (double)a/b;
}
Some guidance would be really appreciated.
Thanks
Martin.
Nov 15 '05 #1
4 6444
I've now noticed that where Visual studio's help states.

"An array of two Byte objects that represent a rational number".
The Exif standard has it as.

"Two Long's".

Assuming that a long in this case is 4 bytes (32 bits) then that would make
more sense for 8 bytes of data.

One more question:
What is an SRational or an SLONG. How do these differ from a Rational or
LONG?
Nov 15 '05 #2
You need to be using 4 byte values, so int is correct, not short. So your
first if statement is the correct one.

Chris R.

"Martin Stainsby" <getenoughspam@alreadythankyou> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
I'm not sure whether I am approaching this correctly?

I'm trying to get the focal length from exif info stored in an image.

The Visual studio help says it is stored in "An array of two Byte objects
that represent a rational number".
Yet there are eight bytes in the info? shown below.

89 00 00 00 0A 00 00 00

Are these supposed to be 2 byte or 4 byte objects, or am I completely
misunderstanding this rational number gizmo?
Both these if statements below retrieve the correct focal length 13.7 that I expect, I'm just not sure if I am approaching the problem correctly in
either case?
if(propertyItem.Id == 0x920A)
{
int a = BitConverter.ToInt32(propItems[count].Value,0);
int b = BitConverter.ToInt32(propItems[count].Value,4);
double focalLength = (double)a/b;
}
if(propertyItem.Id == 0x920A)
{
short a = BitConverter.ToInt16(propItems[count].Value,0);
short b = BitConverter.ToInt16(propItems[count].Value,4);
double focalLength = (double)a/b;
}
Some guidance would be really appreciated.
Thanks
Martin.

Nov 15 '05 #3
The 'S' stands for signed, so that, actually, Rational should use uint/uint
and SRational should use int/uint.
SLONG, in the case of exif, jpeg, and tif files, is a 4 byte signed int
(Int32). LONG is equivalent to UInt32.

Chris R.

"Martin Stainsby" <getenoughspam@alreadythankyou> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
I've now noticed that where Visual studio's help states.

"An array of two Byte objects that represent a rational number".
The Exif standard has it as.

"Two Long's".

Assuming that a long in this case is 4 bytes (32 bits) then that would make more sense for 8 bytes of data.

One more question:
What is an SRational or an SLONG. How do these differ from a Rational or LONG?

Nov 15 '05 #4

"Chris R" <so*****@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
The 'S' stands for signed, so that, actually, Rational should use uint/uint and SRational should use int/uint.
SLONG, in the case of exif, jpeg, and tif files, is a 4 byte signed int
(Int32). LONG is equivalent to UInt32.

Chris R.


Thanks Chris that's been most helpful
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Mike Meyer | last post by:
PEP: XXX Title: A rational number module for Python Version: $Revision: 1.4 $ Last-Modified: $Date: 2003/09/22 04:51:50 $ Author: Mike Meyer <mwm@mired.org> Status: Draft Type: Staqndards...
20
by: Mike Meyer | last post by:
This version includes the input from various and sundry people. Thanks to everyone who contributed. <mike PEP: XXX Title: A rational number module for Python Version: $Revision: 1.4 $...
2
by: Brian van den Broek | last post by:
Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a...
5
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the...
1
by: Alfonso Acosta | last post by:
Hi all, exif_read_data() doesn't support URLs (http://php.net/manual/en/function.exif-read-data.php ) but I would like to do that with the minimum traffic and overhead possible. A naive...
14
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
6
by: penny | last post by:
In this assignment we shall look at a possible representation of rational numbers in java using objects. The java language represents rational numbers using the same representation used for other...
1
by: ben kipkorir | last post by:
In this assignment we shall look at a possible representation of rational numbers in java using objects. The java language represents rational numbers using the same representation used for other...
5
by: anumliaqat | last post by:
hello!! i hav a problem.my program is giving correct outputs for some inputs but wrong results for others. for example if u give (4 2 2)&(2 1 2) to it,it shows all results correct....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.