Incorrect display of numerical exif parameters

Ideas for improvements and requests for new features in XnView Classic

Moderators: helmut, XnTriq, xnview

Post Reply
Alexey Lubkin
Posts: 19
Joined: Tue Nov 01, 2005 7:36 pm

Incorrect display of numerical exif parameters

Post by Alexey Lubkin »

1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
2. Focal length is always looks like "50.0000". Why not just "50" ?
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.
User avatar
xnview
Author of XnView
Posts: 46238
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Incorrect display of numerical exif parameters

Post by xnview »

Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
2. Focal length is always looks like "50.0000". Why not just "50" ?
Could you send me a sample with such fields?
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
Ok

4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.
Perhaps it would be good to customize size like date??
Pierre.
Alexey Lubkin
Posts: 19
Joined: Tue Nov 01, 2005 7:36 pm

Re: Incorrect display of numerical exif parameters

Post by Alexey Lubkin »

xnview wrote:Could you send me a sample with such fields?
I've sent a sample by the email.
xnview wrote:Perhaps it would be good to customize size like date??
I think it's not so important. Everybody probably should accept number formatting like that: "1 234 567".
Alexey Lubkin
Posts: 19
Joined: Tue Nov 01, 2005 7:36 pm

Re: Incorrect display of numerical exif parameters

Post by Alexey Lubkin »

Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
Here is it (MathCancel() - is the function)

Code: Select all

#include <stdio.h>
#include <string>
using namespace std;

void MathCancel(int& p, int& q)
{
  int pp=p,qq=q;
  int tt = pp%qq;
  while(tt)
  {
    pp = qq;
    qq = tt;
    tt = pp%qq;
  }
  p = p / qq;
  q = q / qq;
}

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
string GetString(const int p, const int q)
{
  string tmp("");
  if(q!=1) tmp = "/" + inttostr(q);
  return inttostr(p)+tmp;
}

int main()
{
  int p=10,q=600;
  printf("%d/%d = ",p,q);
  MathCancel(p,q);
  printf("%s\n",GetString(p,q).c_str());
  return 0;
}
User avatar
xnview
Author of XnView
Posts: 46238
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Incorrect display of numerical exif parameters

Post by xnview »

Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];
Pierre.
Victor Snezhko

Re: Incorrect display of numerical exif parameters

Post by Victor Snezhko »

xnview wrote:
Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];
Hmm, but the return type is std::string!
For clarity I would write "return string(buf);"
User avatar
xnview
Author of XnView
Posts: 46238
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Incorrect display of numerical exif parameters

Post by xnview »

Victor Snezhko wrote:
xnview wrote:
Alexey Lubkin wrote:Here is it (MathCancel() - is the function)
Thanks

Code: Select all

string inttostr(const int x)
{
  char buf[32];
  sprintf(buf,"%d",x);
  return buf;
}
Very dangerous, must be static char buf[32];
Hmm, but the return type is std::string!
For clarity I would write "return string(buf);"
Oh sorry i haven't seen string as return value :-)
Pierre.
Alexey Lubkin
Posts: 19
Joined: Tue Nov 01, 2005 7:36 pm

Re: Incorrect display of numerical exif parameters

Post by Alexey Lubkin »

I've just installed the 1.83 RC3 and found that
Alexey Lubkin wrote:1. Exposure time is always looks like "10/600", but should "1/60" instead (BTW, I have my own function written (in C++), which makes this job.)
3. "F-Number" tag returns something like "F2.8", but should "2.8" instead.
is now fixed. Thanks! :)
Alexey Lubkin wrote: 2. Focal length is always looks like "50.0000". Why not just "50" ?
4. The <Size> tag returns size in bytes in the way like "1189701", which is too heavy to read. The string like "1 189 701" would be much better.
And this is still not :(
Alexey Lubkin
Posts: 19
Joined: Tue Nov 01, 2005 7:36 pm

Post by Alexey Lubkin »

Here is the code for doing that

Code: Select all

#include <iostream>
#include <string>

using namespace std;

string ShowNumber(string s)
{
  int i;
  bool enough = false;
  while( !enough && (s.length()>0) && ((i=s.find_last_of("0. "))==s.length()-1) )
  {
    enough = s[i]=='.';
    s.erase(s.length()-1);
  };
  return s;
}

string FormatNumber(string s)
{
  if(s.length()==0) return string("0");
  int i, start = 1+((s.length()+2)%3), count = (s.length()-1)/3;
  for(i=0; i<count; i++)
    s.insert(4*i+start," ");
  return s;
}

int main()
{
  string number = "50.0000";
  cout << "<" << number << "> = <" << ShowNumber(number) << ">\n";

  string filesize = "1234567";
  cout << "<" << filesize << "> = <" << FormatNumber(filesize) << ">\n";

  return 0;
}
And here is the sample output

Code: Select all

<50.0000> = <50>
<1234567> = <1 234 567>
Post Reply