Page 1 of 1

Output double instead of int in postscript code

Posted: 2011-06-29T05:12:31-07:00
by broucaries
we have a bug at debian using an high precision printf see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632065

You output double instead of int for pages and bounding box field (at least on ps.c, but i have not checked ps3 and pdf)

Please also notice that if you use %i and cast to int, that you need to create positive length bounding box so use ceil and floor in order to enforce this.

Bastien

Re: Output double instead of int in postscript code

Posted: 2011-06-29T05:52:41-07:00
by magick
We consistently use %.20g and cast any value to double for printf statements. We conveniently get integers when the value is integer, floats for non-integer values, and scientific notation when the values get larger. The primary benefit is that ImageMagick includes many 64-bit values and %.20g typically handles these gracefully under Linux, Mac, and Windows. That is, we don't need to conditionally compile different embedded formatting to support 64-bit values (one way under Linux, a different way under Windows). However, you are suggesting that the %.20g fails under Debian for a 64-bit integer value and instead produces a floating point value? Can you post the Pages line of the file produced with
  • convert rose: -colorspace Gray test.ps
It would be useful to see the floating point value it produces (We don't have a Debian system). If everything other Linux distributions (i.e. Fedora, Redhat, CentOS, FreeBSD) and Windows produces an integer here, could it be a bug in the Debian printf formatting algorithm? Here is the requisite code:

Code: Select all

           (void) FormatLocaleString(buffer,MaxTextExtent,"%%%%Pages: %.20g\n",
              image_info->adjoin != MagickFalse ? (double)
              GetImageListLength(image) : 1.0);
Sure we can change this one statement to use %i instead but we would need to make this sort of formatting change in about 100 places in ImageMagick. And as mentioned we would need to use different embedded printf formatting for Linux and Windows to support 64-bit integer values.

Re: Output double instead of int in postscript code

Posted: 2011-06-30T08:02:35-07:00
by broucaries
The user use a non compliant IEEE754 float. You could close your bug if you support imagemagick only on IEE754

Re: Output double instead of int in postscript code

Posted: 2011-06-30T08:25:17-07:00
by broucaries
BTW for compatibility over all OS see gnulib http://www.gnu.org/software/gnulib/manu ... rintf.html
It has some nice lgpl code and as a source library could be included in your source