From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/112379 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Henning Hraban Ramm via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: img.scan in lmtx? Date: Thu, 5 Aug 2021 19:00:19 +0200 Message-ID: References: <50BF5AEF-6EE3-4ACE-87F8-1EF9FE4A2397@fiee.net> <65d88310-af79-8c83-6fa2-15a1508ef0a9@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_57E74FA6-D515-4BD2-9AC5-93B0E108F6F7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20568"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Henning Hraban Ramm To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 05 19:01:08 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBgjz-0005Dh-SX for gctc-ntg-context-518@m.gmane-mx.org; Thu, 05 Aug 2021 19:01:07 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 9A17E286427; Thu, 5 Aug 2021 19:00:27 +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 eBQLlDhw9GFi; Thu, 5 Aug 2021 19:00:26 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id DDD4B286424; Thu, 5 Aug 2021 19:00:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id F3E2B28641F for ; Thu, 5 Aug 2021 19:00:23 +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 xHE-ptb3Byd7 for ; Thu, 5 Aug 2021 19:00:22 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=188.68.63.101; helo=relay.yourmailgateway.de; envelope-from=texml@fiee.net; receiver= Original-Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 593D128641B for ; Thu, 5 Aug 2021 19:00:22 +0200 (CEST) Original-Received: from mors-relay-2502.netcup.net (localhost [127.0.0.1]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4GgZc54LRMz58jj for ; Thu, 5 Aug 2021 19:00:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiee.net; s=key2; t=1628182821; bh=VpRdG2pEra8lAq0f0kCRSFNBsvhmdanumuwQTtMlF78=; h=From:Subject:Date:References:To:In-Reply-To:From; b=E79om5ZAXGsCSrzwQlbbmI+nSQTjBN0B9A2PfsRPFZrkUpXdjkGm1d3+7KBCEYYvK H6zEzkmqDH6aQjf1OhuxRyO6xMWn4HEK9ycBoNVCm0PO9rhPfSXJxEpeMXDkvQTpkQ PHY9JfMyx+GbPUG+8fqpHB2L8211vYKLkr8Cbr7zIkXJdE/Q2iQA2OTsfCfNyzJzgG 25o0USOICPjJ7qFBuGccqEdpuAX6mqtICTigZjV/nE1AhOOoDnzuM0n/Hw09cPkPbZ 9qu7LEIvyKX/qor7n/vDMIr4HxfltYIcF9jDr/7PN2PXJ9b/iy7Q0ucREQdGrYmqoA pgAZnRJl0pQ+w== Original-Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4GgZc53xk1z58jh for ; Thu, 5 Aug 2021 19:00:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at policy02-mors.netcup.net Original-Received: from mxf9ac.netcup.net (unknown [10.243.12.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4GgZc46Hq6z8sYF for ; Thu, 5 Aug 2021 19:00:20 +0200 (CEST) Original-Received: from aretsaya.fritz.box (ipservice-092-219-062-073.092.219.pools.vodafone-ip.de [92.219.62.73]) by mxf9ac.netcup.net (Postfix) with ESMTPSA id 32BFE12003D for ; Thu, 5 Aug 2021 19:00:20 +0200 (CEST) Authentication-Results: mxf9ac; spf=pass (sender IP is 92.219.62.73) smtp.mailfrom=texml@fiee.net smtp.helo=aretsaya.fritz.box Received-SPF: pass (mxf9ac: connection is authenticated) In-Reply-To: X-Mailer: Apple Mail (2.3445.104.21) X-PPP-Message-ID: <162818282045.21388.10448786637983087314@mxf9ac.netcup.net> X-PPP-Vhost: fiee.net X-NC-CID: MNc3EeRESR+hG/Z88kpDY5xVBSkUvCc8gvUIE9qp 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.io gmane.comp.tex.context:112379 Archived-At: --Apple-Mail=_57E74FA6-D515-4BD2-9AC5-93B0E108F6F7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Am 05.08.2021 um 17:51 schrieb Hans Hagen : >=20 > On 8/5/2021 12:26 PM, Henning Hraban Ramm via ntg-context wrote: >>> Am 08.07.2021 um 23:09 schrieb Hans Hagen : >>>=20 >>> On 7/8/2021 8:31 PM, Henning Hraban Ramm wrote: >>>>> Am 27.01.2020 um 09:16 schrieb Hans Hagen : >>>>>=20 >>>>> On 1/26/2020 11:50 PM, Henning Hraban Ramm wrote: >>>>>=20 >>>>>> I use the lua function img.scan{filename}, but in lmtx I get = "attempt to index a nil value (global 'img')", so I guess this got = renamed or moved? >>>>> Just the high level command: >>>>>=20 >>>>> figures.getinfo(name,page) >>>=20 >>> local t =3D figures.getinfo("name.pdf",10) -- optional page number >> Finally coming back to this. >> Since I don=E2=80=99t know what the function is supposed to return, I = thought I=E2=80=99ll check: >> local image =3D figures.getinfo(imgname,1) >> print("TEST", image, #image) >> for k, v in ipairs(image) do >> print("TEST", oldname, k, v) >> end >> but that gives only: >> TEST table: 0x7fbd4e4e1320 0 >> i.e. the table is empty. >> Or did I misunderstand something? My Lua skills are still severely = lacking... > it's a hash not an array so .... pairs Oops. Ok, that means the information I=E2=80=99m looking for is in = image.status.private. Who would have thought.=20 Now grph-downsample.lua works with LMTX. Hraban --Apple-Mail=_57E74FA6-D515-4BD2-9AC5-93B0E108F6F7 Content-Disposition: attachment; filename=grph-downsample.lua Content-Type: application/octet-stream; x-unix-mode=0644; name="grph-downsample.lua" Content-Transfer-Encoding: quoted-printable if=20not=20modules=20then=20modules=20=3D=20{=20}=20end=20modules=20= ['grph-downsample']=20=3D=20{=0A=20=20version=20=20=20=3D=201.001,=0A=20=20= comment=20=20=20=3D=20"companion=20to=20grph-inc.mkiv",=0A=20=20author=20= =20=20=20=3D=20"Peter=20M=C3=BCnster",=0A=20=20copyright=20=3D=20"PRAGMA=20= ADE=20/=20ConTeXt=20Development=20Team",=0A=20=20license=20=20=20=3D=20= "see=20context=20related=20readme=20files"=0A}=0A=0Aassert(not=20= figures.getinfo2)=0A=0Afigures.getinfo2=20=3D=20function(name,=20page)=20= --=20[=20[NTG-context]=20Pdf=20info=20with=20Lua/Ctx=20API=20]=0A=20if=20= type(name)=20=3D=3D=20"string"=20then=0A=20=20=20name=20=3D=20{=20name=20= =3D=20name,=20page=20=3D=20page=20}=0A=20end=0A=0A=20if=20name.name=20= then=0A=20=20=20local=20data=20=3D=20figures.push(name)=0A=20=20=20local=20= info=20=3D=20figures.identify()=0A=0A=20=20=20if=20info.status.status=20= ~=3D=200=20then=0A=20=20=20=20=20figures.check()=20--=20!Counts=20pages=20= here!=0A=20=20=20end=0A=0A=20=20=20figures.pop()=0A=0A=20=20=20return=20= --data=0A=20=20=20=20=20=20=20=20=20=20info=0A=20end=0Aend=0A=0A=0Alocal=20= format=20=3D=20string.format=0A--=20figures.cachepaths.path=20=3D=20= "cache"=20--=20should=20be=20setup-option=0Alocal=20function=20= sample_down(oldname,=20newname,=20resolution)=0A=20=20print("DOWNSAMPLE=20= sample_down=20"=20..=20oldname=20..=20"=20to=20"=20..=20newname)=0A=20=20= local=20request=20=3D=20figures.current().request=0A=20=20local=20width=20= =3D=20request.width=0A=20=20local=20height=20=3D=20request.height=0A=20=20= if=20resolution=20=3D=3D=20""=20then=20--=20or=20(not=20width=20and=20= not=20height)=20then=0A=20=20=20=20print(format("DOWNSAMPLE=20Nothing=20= to=20do:=20%s,=20%s,=20%s=20dpi,=20%s=20x=20%s=20px",=20oldname,=20= newname,=20resolution,=20width,=20height))=0A=20=20=20=20return=0A=20=20= end=0A=20=20local=20TEXpt=20=3D=2065536=0A=20=20local=20inch=20=3D=20= 72.27=0A=20=20--=20local=20image=20=3D=20img.scan{filename=20=3D=20= oldname}=0A=20=20local=20image=20=3D=20figures.getinfo(oldname,1)=0A=20=20= image=20=3D=20image.status.private=0A=20=20--[[=0A=20=20= print("DOWNSAMPLE",=20image,=20#image)=0A=20=20for=20k,=20v=20in=20= pairs(image)=20do=0A=20=20=20=20print(k,=20v)=0A=20=20end=0A=20=20width=09= 170506321.92=0A=20=20height=09255759482.88=0A=20=20colordepth=098=0A=20=20= colorspace=092=0A=20=20orientation=091=0A=20=20depth=090=0A=20=20= filename=09img/09115528.jpg=0A=20=20yres=0972=0A=20=20ysize=093888=0A=20=20= transform=090=0A=20=20xres=0972=0A=20=20xsize=092592=0A=20=20rotation=09= 0=0A=20=20]]=0A=20=20--=20STOP=0A=20=20local=20xy=20=3D=20image.xsize=20= /=20image.ysize=0A=20=20if=20(not=20width=20and=20not=20height)=20then=0A= =20=20=20=20--=20no=20size=20requested?=20use=20default=20width=0A=20=20=20= =20width=20=3D=20300=20*=20TEXpt=0A=20=20end=0A=20=20if=20not=20width=20= then=0A=20=20=20=20height=20=3D=20height=20/=20TEXpt=0A=20=20=20=20width=20= =3D=20height=20*=20xy=0A=20=20end=0A=20=20if=20not=20height=20then=0A=20=20= =20=20width=20=3D=20width=20/=20TEXpt=0A=20=20=20=20height=20=3D=20width=20= /=20xy=0A=20=20end=0A=20=20width=20=3D=20math.floor(width)=0A=20=20= height=20=3D=20math.floor(height)=0A=20=20print(format("DOWNSAMPLE=20= image=20size=20%dx%dpx.=20requested=20%dx%d?",=20image.xsize,=20= image.ysize,=20width,=20height))=0A=20=20local=20xsize=20=3D=20= math.floor(resolution=20*=20width=20/=20inch)=0A=20=20local=20ysize=20=3D=20= math.floor(resolution=20*=20height=20/=20inch)=0A=20=20= print(format("DOWNSAMPLE=20size=20%d=20x=20%d=20to=20%d=20x=20%d",=20= image.xsize,=20image.ysize,=20xsize,=20ysize))=0A=20=20if=20xsize=20<=20= image.xsize=20or=20ysize=20<=20image.ysize=20then=0A=20=20=20=20local=20= s=20=3D=20format("gm=20convert=20-resize=20%dx%d=20-resample=20%dx%d=20= %s=20%s",=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= xsize,=20ysize,=20resolution,=20resolution,=20oldname,=20newname)=0A=20=20= =20=20print("DOWNSAMPLE=20Conversion:=20"=20..=20s)=0A=20=20=20=20= os.execute(s)=0A=20=20else=0A=20=20=20=20print(format("DOWNSAMPLE=20= Nothing=20to=20do:=20%s,=20%s,=20%s=20dpi,=20%d=20x=20%d=20px",=20= oldname,=20newname,=20resolution,=20width,=20height))=0A=20=20=20=20--=20= print(format("DOWNSAMPLE=20Nothing=20to=20do:=20%s,=20%s,=20%s",=20= oldname,=20newname,=20resolution))=0A=20=20=20=20= print(format("DOWNSAMPLE=20xsize=20=3D=20%d,=20ysize=20=3D=20%d",=20= xsize,=20ysize))=0A=20=20end=0Aend=0A=0Alocal=20formats=20=3D=20{"png",=20= "jpg",=20"gif"}=0A=0Afor=20_,=20s=20in=20ipairs(formats)=20do=0A=20=20= figures.converters[s]=20=3D=20figures.converters[s]=20or=20{}=0A=20=20= figures.converters[s]["lowres."=20..=20s]=20=3D=20sample_down=0Aend=0A= --Apple-Mail=_57E74FA6-D515-4BD2-9AC5-93B0E108F6F7 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== --Apple-Mail=_57E74FA6-D515-4BD2-9AC5-93B0E108F6F7--