Difference between revisions of "Image Placement"

From ConTeXt wiki
Jump to navigationJump to search
(New! First section: measures)
 
m (optimations)
Line 2: Line 2:
  
 
If you’re using ConTeXt for complex layout tasks, you need to calculate with image sizes. Often it makes sense to use Lua functions.
 
If you’re using ConTeXt for complex layout tasks, you need to calculate with image sizes. Often it makes sense to use Lua functions.
 +
 +
'''Beware''', TeX calculates internally in "scaled points" (sp), 1 sp = 1/65536 pt.
  
 
== Measures in pure ConTeXt ==
 
== Measures in pure ConTeXt ==
  
Beware, TeX calculates internally in "scaled points" (sp), 1 sp = 1/65536 pt.
+
You can get at a picture’s dimensions with one line of TeX code:
  
 
<texcode>
 
<texcode>
\setupexternalfigures[location=default]
+
\setupexternalfigures[location=default] % necessary to find pictures in tree
 
\getfiguredimensions[hacker.jpg]
 
\getfiguredimensions[hacker.jpg]
% defines a bunch of variables, e.g.:
 
\figurefullname
 
\figurefilepath
 
\figurefilename
 
\figurefiletype
 
 
</texcode>
 
</texcode>
 
+
This defines a bunch of variables:
 
<context>
 
<context>
 
\setupexternalfigures[location=default]
 
\setupexternalfigures[location=default]
Line 48: Line 45:
 
\NC \string\figurecolordepth    \NC \figurecolordepth    \NC\NR
 
\NC \string\figurecolordepth    \NC \figurecolordepth    \NC\NR
 
\NC \string\figuredepth        \NC \figuredepth        \NC\NR
 
\NC \string\figuredepth        \NC \figuredepth        \NC\NR
\TB
 
\NC \string\figurefullname      \NC \figurefullname      \NC\NR
 
 
\NC \string\noffigurepages      \NC \noffigurepages ~pages    \NC\NR
 
\NC \string\noffigurepages      \NC \noffigurepages ~pages    \NC\NR
 
\TB
 
\TB
\NC \string\figurefilepath      \NC \figurefilepath      \NC\NR
+
\NC \string\figurefullname      \NC \tfxx\figurefullname      \NC\NR
 +
\NC \string\figurefilepath      \NC \tfxx\figurefilepath      \NC\NR
 
\NC \string\figurefilename      \NC \figurefilename      \NC\NR
 
\NC \string\figurefilename      \NC \figurefilename      \NC\NR
 
\NC \string\figurefiletype      \NC \figurefiletype      \NC\NR
 
\NC \string\figurefiletype      \NC \figurefiletype      \NC\NR
 
\stoptabulate
 
\stoptabulate
 
</context>
 
</context>

Revision as of 20:29, 8 February 2018

< Using–Graphics >

If you’re using ConTeXt for complex layout tasks, you need to calculate with image sizes. Often it makes sense to use Lua functions.

Beware, TeX calculates internally in "scaled points" (sp), 1 sp = 1/65536 pt.

Measures in pure ConTeXt

You can get at a picture’s dimensions with one line of TeX code:

\setupexternalfigures[location=default] % necessary to find pictures in tree
\getfiguredimensions[hacker.jpg]

This defines a bunch of variables: