From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/104721 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Henning Hraban Ramm Newsgroups: gmane.comp.tex.context Subject: Re: lmtx: img? Date: Sat, 03 Aug 2019 07:02:29 +0000 Message-ID: <20190803070229.Horde.hJ_Kt2F9cdfKVMhaPbbaELt@webmail.fiee.net> References: <20190802215905.Horde.aLS0v-eVw04qyQWzpZzseqm@webmail.fiee.net> <3e3b91a4-c479-92a3-ff79-6cfef20667ee@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_OiVT9foD4H6eLN6LsErUE2X" Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="134696"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Horde Application Framework 5 To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sat Aug 03 09:02:58 2019 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hto49-000Yua-Vj for gctc-ntg-context-518@m.gmane.org; Sat, 03 Aug 2019 09:02:58 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 62D77152F5C; Sat, 3 Aug 2019 09:02:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H6Cg06k89882; Sat, 3 Aug 2019 09:02:33 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 824541530FE; Sat, 3 Aug 2019 09:02:33 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 9D6471530CE for ; Sat, 3 Aug 2019 09:02:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SDYm3eyNyPEm for ; Sat, 3 Aug 2019 09:02:30 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=46.163.112.221; helo=fiee.net; envelope-from=texml@fiee.net; receiver= Original-Received: from fiee.net (feronia.fiee.net [46.163.112.221]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id B3408152F5C for ; Sat, 3 Aug 2019 09:02:30 +0200 (CEST) Original-Received: from feronia.fiee.net (feronia.fiee.net [127.0.0.1]) by mail.fiee.net (Postfix) with ESMTPSA id D27E382547 for ; Sat, 3 Aug 2019 09:02:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fiee.net; s=default; t=1564815750; bh=X0hjxtYWDV9zqJclnlebfsgpRH/4+FnD3eSw5uMH6sE=; l=3073; h=Received:From:To:Subject; b=BZ7csSIMgz94k2clwJ9W1ZcYlRzRdUStmiSRTxFbMBrtzbVilscGpLIYD6065h4nO 6NIxk5C7CNF3HQtRJnpJToN5v+wCUssRXahFov6jccZ+GFgEdN7l+xSH2nsejcwyBK SKvd4aPggIRRvhNRICOty6YuEgHFk1Mp8tSgSx9A= Authentication-Results: feronia.fiee.net; spf=pass (sender IP is 127.0.0.1) smtp.mailfrom=texml@fiee.net smtp.helo=feronia.fiee.net Received-SPF: pass (feronia.fiee.net: connection is authenticated) Original-Received: from p5B293B57.dip0.t-ipconnect.de (p5B293B57.dip0.t-ipconnect.de [91.41.59.87]) by webmail.fiee.net (Horde Framework) with HTTPS; Sat, 03 Aug 2019 07:02:29 +0000 In-Reply-To: <3e3b91a4-c479-92a3-ff79-6cfef20667ee@xs4all.nl> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:104721 Archived-At: This message is in MIME format. --=_OiVT9foD4H6eLN6LsErUE2X Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes Content-Disposition: inline Content-Transfer-Encoding: 8bit Zitat von Hans Hagen : > On 8/2/2019 11:59 PM, Henning Hraban Ramm wrote: >> Hi, >> when I try to compile my books with lmtx, it chokes on my Lua image >> library. Seems like "img" (esp. img.scan) is gone. Is there a >> replacement? > It depends on what you want to do ... there are some helpers and I > can add more if needed. There is (and already was) > > local t = figures.getinfo("cow.pdf") Thank you! I had local pic = img.scan{filename = figures.current().status.fullname} and actually just used pic.xsize and pic.ysize to calculate scaling and cropping parameters. There’s probably an easier way to get those. See attachment – I’m trying to calculate the image size to fit into the line grid. Greetlings, Hraban --- https://www.fiee.net http://wiki.contextgarden.net https://www.dreiviertelhaus.de GPG Key ID 1C9B22FD --=_OiVT9foD4H6eLN6LsErUE2X Content-Type: text/x-lua; charset=utf-8; name=grph-imagelib.lua Content-Disposition: attachment; size=1774; filename=grph-imagelib.lua TEXpt = 65536 -- sp per pt TEXptpi = 72.27 -- pt per inch function sp2mm(n) -- convert sp into mm return math.floor(n * 35.28 / TEXpt)/100 end function glue2num(glue) -- convert TeX glue (e.g. skips) into dimensions(? or numbers) return glue.width + (glue.stretch * glue.stretch_order) - (glue.shrink * glue.shrink_order) end function getRegImgHeight(position, resolution, targetwidth) -- position (top/bottom), target resolution [dpi], target width [sp] local pic = img.scan{filename = figures.current().status.fullname} --local pic = figures.getinfo(figures.current().status.fullname) local picH = pic.ysize * TEXptpi * TEXpt / resolution -- picture height in sp local picW = pic.xsize * TEXptpi * TEXpt / resolution -- picture width in sp local bleed = tex.getdimen("Bleed") local lineH = tex.getdimen("lineheight") local scaling = targetwidth / picW -- scaling factor picH = picH * scaling -- scaled image height local nettoPicHeight = picH if position == "bottom" then local bottomOffset = bleed + tex.getdimen("bottomheight") + tex.getdimen("bottomdistance") + tex.getdimen("footerheight") + tex.getdimen("footerdistance") nettoPicHeight = picH - bottomOffset -- image height minus everything below the last line else -- position "top" or whatever local topOffset = bleed + tex.getdimen("topspace") + tex.getdimen("headerheight") + tex.getdimen("headerdistance") + tex.getdimen("topdistance") local topskip = glue2num(tex.topskip) nettoPicHeight = picH - topOffset - topskip -- image height minus everything above the first line end local cutY = math.floor(nettoPicHeight) % math.floor(lineH) -- space to cut away (what exceeds the line grid) context((picH - cutY) .. "sp") -- final image height end --=_OiVT9foD4H6eLN6LsErUE2X Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --=_OiVT9foD4H6eLN6LsErUE2X--