From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/23646 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: ChrisD Newsgroups: gmane.text.pandoc Subject: Lua filter: how to access image properties Date: Mon, 21 Oct 2019 10:48:54 -0700 Message-ID: <64431a4b-8242-1913-49fb-348bc66e5cc2@intielectronics.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="211922"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDHMHIETYAGRBCG7W7WQKGQE2BZMNHY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Oct 21 19:49:00 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-yw1-f64.google.com ([209.85.161.64]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iMbnf-000sx2-F8 for gtp-pandoc-discuss@m.gmane.org; Mon, 21 Oct 2019 19:48:59 +0200 Original-Received: by mail-yw1-f64.google.com with SMTP id l123sf11095992ywd.23 for ; Mon, 21 Oct 2019 10:48:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1571680138; cv=pass; d=google.com; s=arc-20160816; b=0U1UbDvOpcesddToAaMcKT8h6AuBmlNF8KDIbbMIASFDffXgIM/wdT+kOax5AEDaqn qZX6Y5x+KfNg0J7QUw8XxtFZ2+Ujlae8LXS5ASVTKJIeO8boNgxyG4WA0N9hqRUgGKk4 Pm3Y6NC1QCmI4d6avpar1y+LwaA/jTdEHqN5bIxGfd3HvTrE+62Xs7J2ZOGrY70ejahd Wvr1ncmdrwNliXyWsIv4z9GL/AI9qktnWPUFkAE21w6YyrA3rAkuYfsp+r6EXcjSLdc/ 2ASrsMCt71jinheGCQ0TSSLcuhj/vP5wVgRsGSD/xjDQsMAfUNRdfsNaBcnP2TzbgIFA VhYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :subject:from:to:sender:dkim-signature; bh=pHMDSGtKXtVzbh+89SPkNFl4yQyE6yu+7IXyDerYVZw=; b=M68aKd0/5VFmu1SsPZtRmd6LIhFCWcXfcQyxA3ltMDlARel/rJ6enf8fkv31j7SKHf PMIAypi9Xaoh4ac2IFSwe6NDw8/IobZfzlny8ogRXuQEpyMOL0bVF9Vee3S3hhUjs8IE 7m7DpcAsF5D1KDCOVa+AYoX/4nlzlvjLcYZnh6YW7qc1zjAQKBg4YmTI6YL72sHPDP6N w+XtVruu1SmJbxFL/jrWIIO3C8TaLQT25T55koBEMXP1OQXbPd+mImpJ1s5BJuXxJaNs RcC6fmYHtVFSWrsqRj2MUMoX0p6WNykrKiDiTbJw95EK8S/Q+HufuZ6y6nZjowey3q67 5lsg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org designates 209.68.5.143 as permitted sender) smtp.mailfrom=cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=pHMDSGtKXtVzbh+89SPkNFl4yQyE6yu+7IXyDerYVZw=; b=B/6NfwHdhJJBy8D1AoLiL6vxlYN0aY1a5lp5e0j8Bq5kUrb9c+zRulFDhIifvnDSOE BV4Ob6jCCSAC91ECcY5DHY8bhE/THKcJNc11t1U/DYJ8aTO8WNUcb0KXPx4iUZCoeIgv YRIrZ2qNxEjGXHak7o9xEiEwTNQ6AC/I9x5wfiNCflpPJM01YRCmT7CKC8i5WAGd7SEP OR0kcCpvQzv7xfG2k22wWWf/m8tFXNiDuswDYSn3mzQDEt6P7Dzr6CaAR6DhXTVDPJ/j pVgLeV8qp8VTgXOYvio/ZV4p8DeP8bphsAOAA8XKvuU9d0IvNzs9Vy0pDwl9AqyDG4yY CMfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:to:from:subject:message-id:date :user-agent:mime-version:content-transfer-encoding:content-language :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=pHMDSGtKXtVzbh+89SPkNFl4yQyE6yu+7IXyDerYVZw=; b=M7cLrSjzCOtB2g9nmSmqeCbtrYT62hgmigqiEq+OluxGVDUrrC0b/nrZkFZGw4znaH pgAlEDrViYod7gRy/nhrTDxVSPSYLALq1PHnh2hpwqR5Ba2ea5ItW/LBMNWkKcl8BuRf 4XkYVkzyaiIuE11DjbIMcWnnHKfebARQhXwsupFg9JZoN74KOZl2Wzwe5YZQZvt6/VA6 IBH1hjfLJMXqTBGFLYM6FQlwg7UEir2yXMnBUOFCtjnqC1bzjqumzpz0ArdU45Tk5rwX Q6KVqOLnHTB1OQnHU27222PKTgGYyUh+UIl7rjOAeeJoy91pfl98Mi3frBLl/UxLs2zM Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAXj39pLT9Y86OrSyA8zwmdSOo2ZiTNiBBNLO/RYbqiqXPOf6lUc llH9pp17HGl9TkuywDhgCa4= X-Google-Smtp-Source: APXvYqwt6N4nbWnk/tZHHiizvxCBYjme0e/sZdC37/I/KrN6Xoko0h4G2VUJ0zY4IK3Nxeg+Heugrg== X-Received: by 2002:a25:8307:: with SMTP id s7mr8243219ybk.411.1571680138041; Mon, 21 Oct 2019 10:48:58 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a81:5283:: with SMTP id g125ls488561ywb.14.gmail; Mon, 21 Oct 2019 10:48:56 -0700 (PDT) X-Received: by 2002:a0d:e347:: with SMTP id m68mr55640ywe.181.1571680136569; Mon, 21 Oct 2019 10:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571680136; cv=none; d=google.com; s=arc-20160816; b=dRaJb7ljIe52dZ8M+1npD1C+gv9KNzIkZTgPdt5cWdbrzaF86HmIFBufYu+h2JzrID GQBJqyDlvzxqNlOK4n6CWym16RXVQ60b+aDw4xN6JsBwfvbNQ8nPZaqQmcsbhnnY6U67 TG76WNhaKbX4GRN8n+RfBwmgy2DgyH1o9Z+hPbLWgnFhj36dDdRRLMgOK7B9dYhFn23W waVkRVNNWfNpI+yKw/QQIq/kbbW90R/ODtaxv4xOna3aM+qk6SPxvkUPBhqKf6TqfhA6 zLT6guxPm0b1BJPD5rTiSnsDzdbg45SeunJduHNFhQZRONeu2EeA1iGm+cXJN0nke+pg 00XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:content-transfer-encoding:mime-version:user-agent :date:message-id:subject:from:to; bh=wggdDdhhJpoAuQUvrJvKHOnyjp6hAcEPGek4gEcaPPw=; b=FodWrwnSXck3HPyfmq9yXpREU5cC5dBsXIGiP7+cgdGPKPsTT3+sp0u6hIN7LBO1Oe tbzdjhFSpNS2bS/V2SOt+1462LWepi4iwS+u+P1JqTMoYV3O9dFYUM1QGD5u9mZLKhYw TE80efJpbxG8qU+Y/PPmLgLL66PZFnn5p6vbwegxPJXsRWqInzRr2sS0CTz8sMQLCaQ0 wZvMvksjYUZdkDim0nVuKSk2WOVPXcaUR3nYf8OQiZEntTsFjAdezAoeOuTGuraD4aPD p90h2el2YGVeYEXUYMNE4+K26+cXXGPLdp9AKYIh8YBZZzaeEEKDOAVWTcE4Gd+EKL7m zrHw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org designates 209.68.5.143 as permitted sender) smtp.mailfrom=cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org Original-Received: from hamza.pair.com (hamza.pair.com. [209.68.5.143]) by gmr-mx.google.com with ESMTPS id u8si931683ybc.2.2019.10.21.10.48.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Oct 2019 10:48:56 -0700 (PDT) Received-SPF: pass (google.com: domain of cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org designates 209.68.5.143 as permitted sender) client-ip=209.68.5.143; Original-Received: from hamza.pair.com (localhost [127.0.0.1]) by hamza.pair.com (Postfix) with ESMTP id E75CA33E1E for ; Mon, 21 Oct 2019 13:48:55 -0400 (EDT) Original-Received: from [10.31.10.6] (ip-53-36-244-173.west.us.northamericancoax.com [173.244.36.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by hamza.pair.com (Postfix) with ESMTPSA id BCABA33E1A for ; Mon, 21 Oct 2019 13:48:55 -0400 (EDT) Content-Language: en-US X-Original-Sender: cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org designates 209.68.5.143 as permitted sender) smtp.mailfrom=cd34-gg-4SSc53hpTiu9TMao6EloiEEOCMrvLtNR@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:23646 Archived-At: I am trying to write a lua filter that adjusts the width attribute for an i= mage. I want to get the actual dimensions of the image in pixels, and then = set the {width} attribute of the image to the width in pixels. (Motivation: In html output, the default width is already the actual image = width in pixels. But in PDF output, the default width is 100%. I have a lar= ge document with many screenshots, and the screenshots look bad if you resi= ze them. So I am trying to set the width to the actual image width so they = won't be resized in PDF output.) I have written a simple lua filter that processes every image object. In it= I can get el.attributes["width"], which is the value of the {width} attrib= ute in the markdown source (or nil if none is specified). I can set that at= tribute as well. But how do I get the width of the actual image? Is the image in pandoc.mediabag? If so, how do I access it? I found example= s of how to add (insert) new images in the media bag, but not how to find o= nes that should already be there. And if it is in the mediabag, is the widt= h (and height and other properties) available? If the information is not in the media bag, it looks like I can open the or= iginal file using =C2=A0 local im =3D pandoc.Image({}, el.src) but then how do I get the width and height? Also, is there a way to get the full path to the image file? The el.src (wh= ere el is the parameter to the Image function) is the path from the markdow= n. If the image is in a resource directory, I need to prepend the appropria= te path from resource-dir. Ideally the full path to the file is available s= omewhere. If not, is the value of resource-dir available so I can parse it = and search for it myself? In general, is there any additional documentation on the data structures be= yond https://pandoc.org/lua-filters.html? For example, what is the internal= structure of the mediabag. Thanks for your help Chris --=20 You received this message because you are subscribed to the Google Groups "= pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/64431a4b-8242-1913-49fb-348bc66e5cc2%40intielectronics.com.