[gs-devel] resolutions and image widths scaling non-linearly
Russell Lang
gsview at ghostgum.com.au
Tue Apr 29 03:56:59 PDT 2003
On 28 Apr 2003 at 16:51, Lee Howard wrote:
> On 2003.04.28 05:26 Russell Lang wrote:
> > On 26 Apr 2003 at 22:29, Lee Howard wrote:
> >
> > > Using both Ghostscript 6.51 and 7.03 I have a problem with generated
> >
> > > image widths when scaling image resolutions.
> > >
> > > If I do the following...
> > > $ cat somefile.ps | gs -q -sDEVICE=tiffg4 -dNOPAUSE -dSAFER=true
> > > -sPAPERSIZE=letter -dFIXEDMEDIA -r204x392 -sOutputFile=test.tif -
> > >
> > > I get the expected result of...
> > > $ tiffinfo test.tif
> > > TIFF Directory at offset 0x8
> > > Subfile Type: multi-page document (2 = 0x2)
> > > Image Width: 1728 Image Length: 4312
> > > ...
> > > Note that at a resolution of 204x392 pixels/inch the image size is
> > > 1728x4312 pixels on the specified US letter page. These results
> > > generate a US letter page that is 1728/204 = 8.47 by 4312/392 = 11
> > > inches.
> >
> > I get different results with the gs 6.53 and 7.04. I get a
> > width of 1734 pixels which is 8.5 inches.
>
> I get varying sizes, depending on the horizontal resolution. Here's a
> table of my results for letter-size output:
>
> H-Res H-Size-Output H-Size-Calculated
> ----- ------------- -----------------
> 190 1615 1615
> 192 1632 1632
> 194 1649 1649
> 196 1666 1666
> 198 1728* 1683
> 200 1728* 1700
> 202 1728* 1717
> 204 1728* 1734
> 206 1751 1751
> 208 1768 1768
>
> (*) shows a size where gs generates an image size which differs from
> the calculated size. By these results I observe that for some reason
> gs (at least on Linux) is gravitating toward an image-width of 1728
> near the 200 resolution.
>
> It may be coincidental, but 1728 is the requisite image-width per ITU
> T.30 for faxes which are using "R8" (~200 dpi) horizontal resolution.
> I can't help but think that maybe this is an intentional quirk to
> enable compatibility. "R8" means 8 dots per mm which calulates to
> 203.2 dpi and makes 1727.2 dots in 8.5 inches.
>
> Any ideas?
>
> Thanks.
>
> Lee.
If the width is within a certain range, it adjusts it to 1728 as
it writes out the TIFF fax file. Internally it renders it at
1734 pixels wide, but only writes out 1728 columns. gdevfax.c
includes the code below. It doesn't look coincidental at all.
I should have looked more deeply before my first reply.
Perhaps the checks below should only be used if the horizontal
resolution is 204dpi.
/* Initialize the stream state with a set of default parameters. */
/* These select the same defaults as the CCITTFaxEncode filter, */
/* except we set BlackIs1 = true. */
private void
gdev_fax_init_state_adjust(stream_CFE_state *ss,
const gx_device_fax *fdev,
int adjust_width)
{
s_CFE_template.set_defaults((stream_state *)ss);
ss->Columns = fdev->width;
ss->Rows = fdev->height;
ss->BlackIs1 = true;
if (adjust_width > 0) {
/* Adjust the page width to a legal value for fax systems. */
if (ss->Columns >= 1680 && ss->Columns <= 1736) {
/* Adjust width for A4 paper. */
ss->Columns = 1728;
} else if (ss->Columns >= 2000 && ss->Columns <= 2056) {
/* Adjust width for B4 paper. */
ss->Columns = 2048;
}
}
}
Russell Lang gsview at ghostgum.com.au
Ghostgum Software Pty Ltd http://www.ghostgum.com.au/
More information about the gs-devel
mailing list