ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Wrong image size evaluation
@ 2006-05-18 15:00 nico
  2006-05-18 15:28 ` Taco Hoekwater
  0 siblings, 1 reply; 6+ messages in thread
From: nico @ 2006-05-18 15:00 UTC (permalink / raw)


Hello,

I have some troubles with a PNG image, that is not correctly rendered by  
context (too small). The difference I've found with another correctly  
displayed image is that the file does not contain any resolution unit (but  
a pixels/inch default seems reasonable).

Is there a workaround or specific setup to make this work (without  
explicit width setting)?

Here is the test file I use. If you wish I can send the images, or find  
the troublesome PNG image at:  
http://svnbook.red-bean.com/trac/browser/trunk/src/en/book/images/ch01dia1.png?format=raw

Thanks for your help.

\starttext

\startyping
identify -verbose images/ch02dia1.png
images/ch02dia1.png PNG 146x168 146x168+0+0 PseudoClass 135c 2kb 0.008u  
0:01
Image: images/ch02dia1.png
   Format: PNG (Portable Network Graphics)
   Geometry: 146x168
   Resolution: 28.34x28.34
   Units: PixelsPerCentimeter
\stoptyping

\externalfigure[images/ch02dia1.png]

\startyping
identify -verbose images/ch01dia1.png
images/ch01dia1.png PNG 511x585 511x585+0+0 DirectClass 54kb 0.094u 0:01
Image: images/ch01dia1.png
   Format: PNG (Portable Network Graphics)
   Geometry: 511x585
   Resolution: 72x72
   Units: Undefined
\stoptyping

\externalfigure[images/ch01dia1.png]

\stoptext

Regards,
BG

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong image size evaluation
  2006-05-18 15:00 Wrong image size evaluation nico
@ 2006-05-18 15:28 ` Taco Hoekwater
  2006-05-18 16:23   ` nico
  0 siblings, 1 reply; 6+ messages in thread
From: Taco Hoekwater @ 2006-05-18 15:28 UTC (permalink / raw)




nico wrote:
> Hello,
> 
> I have some troubles with a PNG image, that is not correctly rendered by  
> context (too small). The difference I've found with another correctly  
> displayed image is that the file does not contain any resolution unit (but  
> a pixels/inch default seems reasonable).

But pixels/cm is equally reasonable, and that is why pdftex ignores
invalid settings in PNG images completely, and uses its internal
default instead. You can control that default resolution by setting 
\pdfimageresolution to an appropriate guess:

   {\pdfimageresolution=72 \externalfigure[ch01dia1.png]}

Cheers, Taco

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong image size evaluation
  2006-05-18 15:28 ` Taco Hoekwater
@ 2006-05-18 16:23   ` nico
  2006-05-18 17:06     ` Sanjoy Mahajan
  0 siblings, 1 reply; 6+ messages in thread
From: nico @ 2006-05-18 16:23 UTC (permalink / raw)


On Thu, 18 May 2006 17:28:42 +0200, Taco Hoekwater <taco@elvenkind.com>  
wrote:

> nico wrote:
>> Hello,
>>
>> I have some troubles with a PNG image, that is not correctly rendered by
>> context (too small). The difference I've found with another correctly
>> displayed image is that the file does not contain any resolution unit  
>> (but
>> a pixels/inch default seems reasonable).
>
> But pixels/cm is equally reasonable, and that is why pdftex ignores
> invalid settings in PNG images completely, and uses its internal
> default instead. You can control that default resolution by setting
> \pdfimageresolution to an appropriate guess:
>
>    {\pdfimageresolution=72 \externalfigure[ch01dia1.png]}

But 72 means 72 dots per inch, isn't it? The file already contains that  
information (field Resolution given by identify). It's the unit that is  
missing (but when you set pdfimageresolution there isn't any unit either,  
the unit is implicit). But indeed setting the resolution by hand makes it  
work, thanks.

Regards,
BG

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong image size evaluation
  2006-05-18 16:23   ` nico
@ 2006-05-18 17:06     ` Sanjoy Mahajan
  2006-05-18 17:21       ` Taco Hoekwater
  0 siblings, 1 reply; 6+ messages in thread
From: Sanjoy Mahajan @ 2006-05-18 17:06 UTC (permalink / raw)


>> {\pdfimageresolution=72 \externalfigure[ch01dia1.png]}

> when you set pdfimageresolution there isn't any unit either, the
> unit is implicit

What about a new pdftex primitive: \pdfimagepixel, which would force
using a unit.  Then the above would be done by \pdfimagepixel=1bp

This subject is dear to me because (1) I'm writing a textbook on
dimensional analysis, and (2) almost none of my students use units in
their assignments, and often therefore make absurd mistakes.  That's
what happened to the NASA Mars probe that crashed into the surface
after travelling all the way.  The engine makers and NASA had
different ideas of what units the thrust was in (I think NASA had
converted to SI units, whereas the manufacturer used 'English' units).

-Sanjoy

`Never underestimate the evil of which men of power are capable.'
         --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong image size evaluation
  2006-05-18 17:06     ` Sanjoy Mahajan
@ 2006-05-18 17:21       ` Taco Hoekwater
  2006-05-18 20:29         ` gnwiii
  0 siblings, 1 reply; 6+ messages in thread
From: Taco Hoekwater @ 2006-05-18 17:21 UTC (permalink / raw)


Sanjoy Mahajan wrote:
>>>{\pdfimageresolution=72 \externalfigure[ch01dia1.png]}
> 
>>when you set pdfimageresolution there isn't any unit either, the
>>unit is implicit

It is defined to be an integer number of pixels per inch, in the
pdftex manual.

> What about a new pdftex primitive: \pdfimagepixel, which would force
> using a unit.  Then the above would be done by \pdfimagepixel=1bp

You can (as always) propose it on the pdftex list, but i personally
do not see the point. Bear in mind that the png spec is extremely
clear on the use pHYs:

   If this ancillary chunk is not present, pixels are assumed to be
   square, and the physical size of each pixel is unknown.

So the problem was created way before pdftex came into play.

Cheers, Taco

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Wrong image size evaluation
  2006-05-18 17:21       ` Taco Hoekwater
@ 2006-05-18 20:29         ` gnwiii
  0 siblings, 0 replies; 6+ messages in thread
From: gnwiii @ 2006-05-18 20:29 UTC (permalink / raw)


On 5/18/06, Taco Hoekwater <taco@elvenkind.com> wrote:
> > What about a new pdftex primitive: \pdfimagepixel, which would force
> > using a unit.  Then the above would be done by \pdfimagepixel=1bp
>
> You can (as always) propose it on the pdftex list, but i personally
> do not see the point. Bear in mind that the png spec is extremely
> clear on the use pHYs:
>
>    If this ancillary chunk is not present, pixels are assumed to be
>    square, and the physical size of each pixel is unknown.
>
> So the problem was created way before pdftex came into play.

Pdftex's image inclusion should be viewed as a convenience feature
that is nice when it works, but it is no substitute for using good
external software to create good images (preferrably in pdf format so
no conversions are needed).  Once you have support for
including images you have to deal with questions of what should be
supported, and to which the only good answer is "any image George's
boss wants to use".  By offloading such questions onto the authors of
sam2p, imagemagick, netpbm, gimp, cinepaint, Photoshop, etc. there is
time for more texy questions that those authors won't address.

-- 
George N. White III <aa056@chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-18 20:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-18 15:00 Wrong image size evaluation nico
2006-05-18 15:28 ` Taco Hoekwater
2006-05-18 16:23   ` nico
2006-05-18 17:06     ` Sanjoy Mahajan
2006-05-18 17:21       ` Taco Hoekwater
2006-05-18 20:29         ` gnwiii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).