[NTG-context] export images

Wolfgang Schuster schuster.wolfgang at gmail.com
Sat Mar 21 13:11:24 CET 2015


> Am 21.03.2015 um 12:01 schrieb Idris Samawi Hamid ادريس سماوي حامد <ishamid at colostate.edu>:
> 
> On Sat, 21 Mar 2015 02:55:08 -0600, Wolfgang Schuster <schuster.wolfgang at gmail.com <mailto:schuster.wolfgang at gmail.com>> wrote:
> 
>> 
>>> Am 21.03.2015 um 03:09 schrieb Idris Samawi Hamid ادريس سماوي حامد <ishamid at colostate.edu>:
>>> 
>>> Dear gang,
>>> 
>>> How do we get images in the export? Here is my sample (also attached):
>>> 
>>> ==============
>>> \setupbackend[export=yes]
>>> 
>>> \starttext
>>> \startalignment [middle]
>>> \dontleavehmode
>>> \externalfigure[mill.png]
>>> \stopalignment
>>> \stoptext
>>> ==============
>>> 
>>> div output:
>>> 
>>> ==
>>> <div>
>>>  <div class="image" id="image-1"><!--empty--></div>
>>> </div>
>>> ==
>>> 
>>> So it seems that \externalfigure[mill.png] is tagged in the output but the
>>> image itself is ignored. What am I missing here? pdf output is correct; I
>>> copied mill.png from the context sample folder
>>> 
>>> /tex/texmf-context/tex/context/sample/mill.png
>> 
>> Put mill.png in the images folder which should exist in the export folder.
> 
> Thanks, Wolfgang!
> 
> One more question on this: How can I setup the images so that I don't have to toggle, e.g.
> 
> \externalfigure[basmalah.png][width=3in]
> % \externalfigure[basmalah.pdf][width=3in]
> 
> Is there a way to tell the export to use the png option, while telling the pdf output to use the pdf? This is important when the image is made from a font (no needs scalability in the pdf).

You can try to use the *export mode to use different images for the XML and PDF output.


The first method is to drop the file extension and tell context to use the PNG files when the export is enabled.

%\setupbackend[export=yes] % uncomment to enable *export mode

\startmode[*export]
  \useexternalfigure[basmalah] [basmalah.png]
\stopmode

% possible but not necessary because ConTeXt prefers images in the PDF format
%
% \startnotmode[*export]
%   \useexternalfigure[basmalah] [basmalah.pdf]
% \stopnotmode

\starttext
\externalfigure[basmalah]
\stoptext


The second method is to specify which image should be used when the export is disabled/enabled.

%\setupbackend[export=yes] % uncomment to enable *export mode

\starttext

\doifmodeelse{*export}
  {\externalfigure[basmalah.png]}
  {\externalfigure[basmalah.pdf]}

\stoptext


The third method is to use two folders for the images in PDF and PNG format.

%\setupbackend[export=yes] % uncomment to enable *export mode

\doifmodeelse[*export]
  {\setupexternalfigures[directory=pngimages]}
  {\setupexternalfigures[directory=pdfimages]}

\starttext
\externalfigure[basmalah]
\stoptext


Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150321/d0b1d7b5/attachment.html>


More information about the ntg-context mailing list