summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/sources/general/manuals/workflows/workflows-graphics.tex47
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4388 -> 4384 bytes
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/grph-inc.lua83
-rw-r--r--tex/context/base/publ-ini.lua8
-rw-r--r--tex/context/base/status-files.pdfbin24657 -> 24671 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin343150 -> 343152 bytes
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
9 files changed, 134 insertions, 10 deletions
diff --git a/doc/context/sources/general/manuals/workflows/workflows-graphics.tex b/doc/context/sources/general/manuals/workflows/workflows-graphics.tex
index 549b8b9f2..25eed7bee 100644
--- a/doc/context/sources/general/manuals/workflows/workflows-graphics.tex
+++ b/doc/context/sources/general/manuals/workflows/workflows-graphics.tex
@@ -83,6 +83,53 @@ and suitable action can be taken.
\stopsection
+\startsection[title=Downsampling]
+
+You can plug in you rown converter, here is an example:
+
+\starttyping
+\startluacode
+
+figures.converters.jpg = figures.converters.jpg or { }
+
+figures.converters.jpg["lowresjpg.pdf"] =
+ function(oldname,newname,resolution)
+ figures.programs.run (
+ [[gm]],
+ [[convert -geometry %nx%x%ny% -compress JPEG "%old%" "%new%"]],
+ {
+ old = old,
+ new = new,
+ nx = resolution or 300,
+ ny = resolution or 300,
+ }
+ )
+ end
+\stopluacode
+\stoptyping
+
+You can limit the search to a few types and set the resolution with:
+
+\starttyping
+\setupexternalfigures
+ [order={pdf,jpg},
+ resolution=100,
+ method=auto]
+\stoptyping
+
+And use it like:
+
+\starttyping
+\externalfigure[verybig.jpg][height=10cm]
+\stoptyping
+
+The second string passed to the \type {run} helper contains the arguments to the
+first one. The variables between percent signs get replaced by the variables in
+the tables passed as third argument.
+
+\stopsection
+
\stopchapter
\stopcomponent
+
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index a866d0895..9891ab046 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2015.03.09 22:02}
+\newcontextversion{2015.03.10 12:09}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 5d7728e18..2c2c7b0a5 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index e8f7e49af..7d6259737 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2015.03.09 22:02}
+\edef\contextversion{2015.03.10 12:09}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 56581ddf3..d795deacf 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -69,7 +69,7 @@ local texsetbox = tex.setbox
local hpack = node.hpack
-local new_latelua = nodes.pool.latelua
+local new_latelua = nodes.pool.latelua
local context = context
@@ -105,18 +105,35 @@ local maxdimen = 2^30-1
function images.check(figure)
if figure then
- local width = figure.width
+ local width = figure.width
local height = figure.height
+ if width <= 0 or height <= 0 then
+ report_inclusion("image %a has bad dimensions (%p,%p), discarding",
+ figure.filename,width,height)
+ return false, "bad dimensions"
+ end
+ local xres = figure.xres
+ local yres = figure.yres
+ local changes = false
if height > width then
if height > maxdimen then
figure.height = maxdimen
figure.width = width * maxdimen/height
- report_inclusion("limiting natural dimensions of %a (%s)",figure.filename,"height")
+ changed = true
end
elseif width > maxdimen then
figure.width = maxdimen
figure.height = height * maxdimen/width
- report_inclusion("limiting natural dimensions of %a (%s)",figure.filename,"width")
+ changed = true
+ end
+ if changed then
+ report_inclusion("limiting natural dimensions of %a, old %p * %p, new %p * %p",
+ figure.filename,width,height,figure.width,figure.height)
+ end
+ if width >=maxdimen or height >= maxdimen then
+ report_inclusion("image %a is too large (%p,%p), discarding",
+ figure.filename,width,height)
+ return false, "dimensions too large"
end
return figure
end
@@ -594,8 +611,9 @@ local function rejected(specification)
if extra_check then
local fullname = specification.fullname
if fullname and figures_native[file.suffix(fullname)] and not figures.guess(fullname) then
- specification.comment = "probably a bade file"
+ specification.comment = "probably a bad file"
specification.found = false
+ specification.error = true
report_inclusion("file %a looks bad",fullname)
return true
end
@@ -1097,8 +1115,52 @@ function figures.check(data)
return (checkers[data.status.format] or checkers.generic)(data)
end
+local trace_usage = false
+local used_images = { }
+
+trackers.register("graphics.usage", function(v)
+ if v and not trace_usage then
+ luatex.registerstopactions(function()
+ local found = { }
+ for _, t in table.sortedhash(figures_found) do
+ found[#found+1] = t
+ for k, v in next, t do
+ if v == false or v == "" then
+ t[k] = nil
+ end
+ end
+ end
+ for i=1,#used_images do
+ local u = used_images[i]
+ local s = u.status
+ if s then
+ s.status = nil -- doesn't say much here
+ if s.error then
+ u.used = { } -- better show that it's not used
+ end
+ end
+ for _, t in next, u do
+ for k, v in next, t do
+ if v == false or v == "" then
+ t[k] = nil
+ end
+ end
+ end
+ end
+ table.save(file.nameonly(environment.jobname) .. "-figures-usage.lua",{
+ found = found,
+ used = used_images,
+ } )
+ end)
+ trace_usage = true
+ end
+end)
+
function figures.include(data)
data = data or callstack[#callstack] or lastfiguredata
+ if trace_usage then
+ used_images[#used_images+1] = data
+ end
return (includers[data.status.format] or includers.generic)(data)
end
@@ -1187,10 +1249,17 @@ function checkers.generic(data)
codeinjections.setfigurecolorspace(data,figure)
codeinjections.setfiguremask(data,figure)
if figure then
- figure = images.check(images.scan(figure)) or false
+ local f, comment = images.check(images.scan(figure))
+ if not f then
+ ds.comment = comment
+ ds.found = false
+ ds.error = true
+ end
+ figure = f
end
local f, d = codeinjections.setfigurealternative(data,figure)
- figure, data = f or figure, d or data
+ figure = f or figure
+ data = d or data
figures_loaded[hash] = figure
if trace_conversion then
report_inclusion("new graphic, using hash %a",hash)
diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua
index bef506141..f20bf5102 100644
--- a/tex/context/base/publ-ini.lua
+++ b/tex/context/base/publ-ini.lua
@@ -549,6 +549,10 @@ local findallused do
tags[#tags+1] = tag
end
end
+ if #tags == 0 and not reported[reference] then
+ tags[1] = reference
+ reported[reference] = true
+ end
else
for i=1,#tags do
local tag = tags[i]
@@ -571,6 +575,10 @@ local findallused do
todo[tag] = true
end
end
+ if #tags == 0 and not reported[reference] then
+ tags[1] = reference
+ reported[reference] = true
+ end
else
for i=1,#tags do
local tag = tags[i]
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index c2e5ee261..fc9fe0003 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 317f1e8b5..0a2a851dc 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index bbd5ac5e0..b6621525a 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 03/09/15 22:02:23
+-- merge date : 03/10/15 12:09:17
do -- begin closure to overcome local limits and interference