• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 14502192980

16 Apr 2025 08:26PM UTC coverage: 57.267% (-5.4%) from 62.627%
14502192980

push

github

alerque
chore(packages): Remove unused package interdependency, url doesn't need verbatim

Reported-by: Omikhleia <didier.willis@gmail.com>

12352 of 21569 relevant lines covered (57.27%)

871.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/image/init.lua
1
local base = require("packages.base")
×
2

3
local package = pl.class(base)
×
4
package._name = "image"
×
5

6
function package:registerCommands ()
×
7
   self:registerCommand("img", function (options, _)
×
8
      SU.required(options, "src", "including image file")
×
9
      local width = SU.cast("measurement", options.width or 0):tonumber()
×
10
      local height = SU.cast("measurement", options.height or 0):tonumber()
×
11
      local pageno = SU.cast("integer", options.page or 1)
×
12
      local src = SILE.resolveFile(options.src) or SU.error("Couldn't find file " .. options.src)
×
13
      local box_width, box_height, _, _ = SILE.outputter:getImageSize(src, pageno)
×
14
      local sx, sy = 1, 1
×
15
      if width > 0 and height > 0 then
×
16
         sx, sy = box_width / width, box_height / height
×
17
      elseif width > 0 then
×
18
         sx = box_width / width
×
19
         sy = sx
×
20
      elseif height > 0 then
×
21
         sy = box_height / height
×
22
         sx = sy
×
23
      end
24
      SILE.typesetter:pushHbox({
×
25
         width = box_width / sx,
26
         height = box_height / sy,
27
         depth = 0,
28
         value = src,
29
         outputYourself = function (node, typesetter, _)
30
            SILE.outputter:drawImage(
×
31
               node.value,
×
32
               typesetter.frame.state.cursorX,
×
33
               typesetter.frame.state.cursorY - node.height,
×
34
               node.width,
×
35
               node.height,
×
36
               pageno
37
            )
38
            typesetter.frame:advanceWritingDirection(node.width)
×
39
         end,
40
      })
41
   end, "Inserts the image specified with the <src> option in a box of size <width> by <height>")
×
42
end
43

44
package.documentation = [[
45
\begin{document}
46
Loading the \autodoc:package{image} package gives you the \autodoc:command{\img} command, fashioned after the HTML equivalent.
47
It takes the following parameters: \autodoc:parameter{src=<file>} must be the path to an image file; you may also give \autodoc:parameter{height} and/or \autodoc:parameter{width} parameters to specify the output size of the image on the paper.
48
If the size parameters are not given, then the image will be output at its “natural” size, honoring its resolution if available.
49
The command also supports a \autodoc:parameter{page=<number>} option, to specify the selected page in formats supporting
50
several pages (such as PDF).
51

52
\begin{autodoc:note}
53
With the libtexpdf backend (the default), the images can be in JPEG, PNG, EPS, or PDF formats.
54
\end{autodoc:note}
55

56
Here is a 200x243 pixel image output with \autodoc:command{\img[src=documentation/gutenberg.png]}.
57
The image has a claimed resolution of 100 pixels per inch, so ends up being two inches (144pt) wide on the page:\par
58
\img[src=documentation/gutenberg.png]
59

60
\raggedright{
61
Here it is with (respectively)
62
\autodoc:command{\img[src=documentation/gutenberg.png,width=120pt]},
63
\autodoc:command{\img[src=documentation/gutenberg.png,height=200pt]}, and
64
\autodoc:command{\img[src=documentation/gutenberg.png,width=120pt,height=200pt]}:}
65

66
\img[src=documentation/gutenberg.png,width=120pt]
67
\img[src=documentation/gutenberg.png,height=200pt]
68
\img[src=documentation/gutenberg.png,width=120pt,height=200pt]
69

70
Notice that images are typeset on the baseline of a line of text, rather like a very big letter.
71
\end{document}
72
]]
×
73

74
return package
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc