Changes

Jump to navigation Jump to search
m
Fixed one typo, one small grammatical error.
== File Formats ==
ConTeXt natively supports the image formats enumerated below. The image format is determined from the file extension (case insensitive).
* '''PDF''': File extension <tt>.pdf</tt>
<td align="left"><strong>GIF</strong></td>
<td align="left"><code>.gif</code></td>
<td align="left"><code>gmconvert</code> from GraphicsMagick</td>
</tr>
<tr class="odd">
<td align="left"><strong>TIFF</strong></td>
<td align="left"><code>.tiff</code></td>
<td align="left"><code>gmconvert</code> from GraphicsMagick</td></tr><tr class="even"><td align="left"><strong>BMP</strong></td><td align="left"><code>.bmp</code></td><td align="left"><code>gm convert</code> from GraphicsMagick</td>
</tr>
</table>
The conversion generates a PDF file with prefix <tt>m_k_i_v_</tt> and a suffix <tt>.pdf</tt> added to the name of the original file. The result is cached, and the conversion is rerun re-run if the timestamp of the original file is newer than that of the converted file. In LMTX, the file name contains a MD5 hash of the relevant source image parameters (resolution, dimensions, ...), e.g.: <pre>hacker_jpg_c60ccda70ef92e32d7a6334f31c23259.gray.pdf </pre>
It is possible to change the converter used with the following code:
<pre>
\startluacode
local function converterdownsampler(oldname, newname, resolution)
if not resolution or resolution == "" then
resolution = 50
end
os.execute(string.format(
'gm convert -density %ix%i "%s" "%s"',
resolution, resolution, oldname, newname)
)
-- Set the PDF and default TIFF converters to the above function.
figures.converters.tif.pdf = converterdownsamplerfigures.converters.tif.default = converterdownsampler-- Hint: This works also for jpg or png!
\stopluacode
</pre>
See also: https://source.contextgarden.net/tex/context/base/mkiv/{{src|grph-inc.lua}}
== Interaction ==
<texcode>\setupexternalfigures[location={local,global}]</texcode>
The ConTeXt distribution includes three sample images: <tt>cow.pdf</tt>, <tt>mill.png</tt>, and <tt>hacker.jpg</tt>, that are useful when creating minimum working examples to illustrate a bug on the mailing list. These images are locating located in the <tt>TEXMF</tt> directory. To add the <tt>TEXMF</tt> directory to the image search path, use:
<texcode>\setupexternalfigures[location={local,global,default}]</texcode>
When a document containing a remote file is compiled for the first time, the remote file is downloaded from the server and stored in the LuaTeX cache directory. This cached file is used during subsequent runs.
Normally, the remote image is downloaded again if the image in the cache is older than 1~day. To change this threshold to, for example, 2<sub>minutes (120</sub>seconds), either add
<texcode>\enabledirectives[schemes.threshold=120]</texcode>
context.externalfigure({"memstream:///inline"})
\stopluacode
</texcode>
 
== Custom Processing ==
 
The following example changes the width of images based on file name extensions:
 
<texcode>
\setupexternalfigures[
location={local,global,default},
width=\textwidth
]
\defineexternalfigure[svg][width=1cm]
\defineexternalfigure[jpg][width=2cm]
\defineexternalfigure[png][width=4cm]
 
% Won't be applied because there's no process action.
% Default (\textwidth) is used, as defined above.
\defineexternalfigure[pdf][width=6cm]
 
\starttexdefinition includegraphics #1
\splitfilename{#1}
 
\processaction[\splitofftype][
jpg=>{\externalfigure[#1][jpg]},
png=>{\externalfigure[#1][png]},
svg=>{\externalfigure[#1][svg][conversion=mp]},
default=>{\externalfigure[#1]},
unknown=>{\externalfigure[#1]}
]
\stoptexdefinition
 
\starttext
\includegraphics{kitten.jpg}
\includegraphics{mill.png}
\includegraphics{cow.pdf}
\includegraphics{tiger.svg}
\stoptext
</texcode>
 
It's also possible to use {{cmd|setfigureconversion}} to instruct ConTeXt to use MetaPost when rendering SVG files. Such as:
 
<texcode>
\setfigureconversion[svg][mp]
 
\starttext
\externalfigure[kitten.jpg][width=2cm]
\externalfigure[mill.png] [width=4cm]
\externalfigure[cow.pdf] [width=6cm]
\externalfigure[tiger.svg] [width=1cm]
\stoptext
</texcode>
== Image Scaling ==
 
{{ note | If either <tt>width</tt> or <tt>height</tt> is specified, then the <tt>scale</tt> key has no effect. }}
 
To scale an image use the <tt>scale</tt> key: <tt>scale=1000</tt> corresponds to the original dimensions of the image, <tt>scale=500</tt> scales the image to 50% of the original size, <tt>scale=1500</tt> scales the images to 150% of the original size, and so on. For example:
<texcode>\externalfigure[logo.pdf][scale=500]</texcode>
 
scales the image to 50% of its size.
Use <tt>\setupexternalfigures</tt> to set the scale of all images. For example, to scale all images to be twice their original size, use:
<texcode>\setupexternalfigures[scale=2000]</texcode>
 
If either <tt>width</tt> or <tt>height</tt> is specified, then the <tt>scale</tt> key has no effect.
In addition, the <tt>xscale</tt> and <tt>yscale</tt> keys scale the image in only one dimension. For example:
<tt>preview=yes</tt> shows the first image as preview.
You find more about interactive Elements in [http://www.pragma-ade.comnl/general/manuals/mwidget-s.pdf mwidget-s.pdf]
Unfortunately, people who are fond of Linux cannot embed movies because the linux Linux release of acroread doesn't support that. An alternative solution consists in launching your prefered player (MPlayer) from acroread:
<texcode>
38

edits

Navigation menu