ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henning Hraban Ramm <texml@fiee.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: degrade module
Date: Fri, 15 Feb 2019 08:24:50 +0100	[thread overview]
Message-ID: <34275BF1-3CCF-4E06-8BB5-7E23A361345C@fiee.net> (raw)
In-Reply-To: <B9CDCD39-A72E-4E31-B971-819B83D22781@toppkieker.info>

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Am 2019-02-15 um 07:56 schrieb Lutz Haseloff <lutz.haseloff@toppkieker.info>:

> Thank you all for your help.
> 
> First i tried the grph-downsample.lua script.
> Unfortunately i get an error message
> grph-downsample.lua:31: bad argument #2 to 'format' (number has no integer representation)
> See attached log file.

It’s a problem due to changes in Lua between 5.2 and 5.3 (or the like).
The attached version works (for me).


Greetlings, Hraban
---
https://www.fiee.net
http://wiki.contextgarden.net
https://www.dreiviertelhaus.de
GPG Key ID 1C9B22FD



[-- Attachment #2: grph-downsample.lua --]
[-- Type: application/octet-stream, Size: 1601 bytes --]

if not modules then modules = { } end modules ['grph-downsample'] = {
  version   = 1.001,
  comment   = "companion to grph-inc.mkiv",
  author    = "Peter Münster",
  copyright = "PRAGMA ADE / ConTeXt Development Team",
  license   = "see context related readme files"
}

local format = string.format
-- figures.cachepaths.path = "cache" -- should be setup-option
local function sample_down(oldname, newname, resolution)
  local request = figures.current().request
  local width = request.width
  local height = request.height
  if resolution == "" or (not width and not height) then
    print(format("Nothing to do: %s, %s, %s", oldname, newname, resolution))
    return
  end
  local TEXpt = 65536
  local inch = 72.27
  local image = img.scan{filename = oldname}
  local xy = image.xsize / image.ysize
  if not width then
    width = height * xy / TEXpt
  end
  if not height then
    height = width / xy / TEXpt
  end
  local xsize = resolution * width / inch
  local ysize = resolution * height / inch
  if xsize < image.xsize or ysize < image.ysize then
    local s = format("gm convert -resize %dx%d %s %s",
                     xsize, ysize, oldname, newname)
    print("Conversion: " .. s)
    os.execute(s)
  else
    print(format("Nothing to do: %s, %s, %s", oldname, newname, resolution))
    print(format("xsize = %d, ysize = %d", xsize, ysize))
  end
end

local formats = {"png", "jpg", "gif"}

for _, s in ipairs(formats) do
  figures.converters[s] = figures.converters[s] or {}
  figures.converters[s]["lowres." .. s] = sample_down
end

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2019-02-15  7:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 19:49 Lutz Haseloff
2019-02-14 20:22 ` Marco Patzer
2019-02-14 20:37   ` Peter Münster
2019-02-14 20:32 ` Peter Münster
2019-02-14 20:41   ` Wolfgang Schuster
2019-02-14 21:00     ` Peter Münster
2019-02-14 20:44   ` Hans Hagen
2019-02-15  6:56     ` Lutz Haseloff
2019-02-15  7:24       ` Henning Hraban Ramm [this message]
2019-02-15  7:25       ` Marco Patzer
2019-02-15  9:22         ` Lutz Haseloff
2019-02-15 10:08           ` Marco Patzer
2019-02-15 10:48             ` Lutz Haseloff
2019-02-15 11:23               ` Marco Patzer
2019-02-17 11:14                 ` Peter Münster
2019-02-18  9:13                   ` Marco Patzer
2019-02-18 10:03                     ` Peter Münster
2019-02-18 15:25                     ` Alan Braslau
2019-02-18 21:09                       ` Peter Münster
2019-02-18 21:23                         ` Alan Braslau
2019-02-18 22:50                           ` Peter Münster
2019-02-18 23:21                             ` Alan Braslau
2019-02-19  9:42                               ` Peter Münster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34275BF1-3CCF-4E06-8BB5-7E23A361345C@fiee.net \
    --to=texml@fiee.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).