Re: Pixels per Inch [message #37371] |
Tue, 16 December 2003 09:03  |
sdj
Messages: 20 Registered: November 2003
|
Junior Member |
|
|
Dear JD et al,
Thanks for your help.
I was wondering if it would be possible to read all the 'PNG' images I
already created (using the "read_png" routine) and then converting
them to 'PostScript'. I could thus set the desired resolution while
creating the new 'PostScript' image. Would this approach work ?
My real problem is that I want the new images to have the same
"physical size" as before, but with increased resolution. How can I do
this ? Do I set the resolution using the 'xsize' and 'ysize' keywords
in "device" ?
I had a look at the IDL help pages and came up with an example that
made me write the following simple program. The problem is that I
don't know how to keep the "physical size" while increasing the
resolution.
;******************
PRO PNG2PS, in_file
;Read the PNG file.
img = read_png(in_file, r, g, b)
;Reconstruct the color table.
tvlct, r,g,b
;Display the image in an IDL window.
tv, img
;Find the size of the picture.
s = size(img)
;Take the `png' extension off of the old filename and replace it with
`ps'.
fl = strlen(in_file)
file = strmid(in_file, 0, fl-4)
out_file = file + '.ps'
;Set the plotting device to PostScript.
set_plot, 'ps'
;Use the DEVICE procedure to make the output PostScript
device, bits_per_pixel = 8, /color, filename = out_file, xsize = ??,
ysize = ??
;Write the image to the file.
tv, img
;Close the file.
device, /close
END
;*************
Thanks again for the help and excuse me for insisting on this "simple"
problem.
Regards,
Pepe
> On Mon, 15 Dec 2003 13:20:08 -0700, Craig Markwardt wrote:
>
>
>> JD Smith <jdsmith@as.arizona.edu> writes: [ ... ]
>>> It depends on how many "inches" you intend to output the image to. This
>>> is a basic and common mis-understanding of how image resolution works.
>>> A bitmap image like a PNG file has a specific size in pixels, nxm say,
>>> but does not have an associated "physical size". The
>>
>>
>> JD, I'm not sure that's always true. I believe that TIFF images have an
>> inherent (desired) dot pitch. Perhaps other formats do too, but PNGs
>> definitely do not, so your comment is appropriate for the original
>> poster.
>
> Actually, PNG also has an optional header chunk called "pHYs" which gives
> the pixels per meter. Other image formats have something similar. My
> main point was that, no matter what you put in the header regarding the
> "physical size" of the image, this is only a suggestion, and has no
> bearing on the resolution or detail present in your image. Many programs
> explicitly ignore these data (especially for on-screen display). You have
> to separate the notion of resolution as "convenient suggestions for
> printing and print layout programs" vs. resolution as real physical detail
> present in the image.
>
> The program pngcrush can add, change or remove the pHYs resolution
> information from PNG files (http://pmt.sourceforge.net/pngcrush). But,
> for example, if I take a PNG file and give it resolution 300dpi, 50dpi,
> and no resolution, the three version display exactly the same in all
> browsers, and the Gimp.
>
> JD
|
|
|