ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>,
	Rudolf Bahr <quasi@quasi.de>
Subject: Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
Date: Sat, 23 Feb 2019 12:48:31 +0100	[thread overview]
Message-ID: <15bcb709-2612-df32-c839-7eb06545fe5f@xs4all.nl> (raw)
In-Reply-To: <20190223113742.rdzu4kt4bl6v4auf@nan>

On 2/23/2019 12:37 PM, Rudolf Bahr wrote:
> On Sat, Feb 23, 2019 at 11:56:32AM +0100, Hans Hagen wrote:
>> On 2/23/2019 11:08 AM, Rudolf Bahr wrote:
>>> On Fri, Feb 22, 2019 at 12:59:55PM +0100, Peter Münster wrote:
>>>> On Fri, Feb 22 2019, Rudolf Bahr wrote:
>>>>
>>>>> The picture sizes in px One gets by invoking for instance graphics Magick's identify
>>>>> in a lua program:
>>>>
>>>> Or just img.scan():
>>>>
>>>> \startluacode
>>>>     local image = img.scan{filename = "my-image.jpg"}
>>>>     logs.report("xsize", image.xsize)
>>>>     logs.report("ysize", image.ysize)
>>>> \stopluacode
>>>>
>>>> -- 
>>>>              Peter
>>>
>>> Hi Peter,
>>>
>>> thank you for pointing to img.scan{}! It's indeed shorter than to invoke Graphics Magick
>>> in Lua. Remains the conversion of image sizes into pt. There is an example in the chapter
>>> "Calculations in Lua" in "https://wiki.contextgarden.net/Image_Placement" (a work in
>>> progress). According to there it's necessary to know the resolution in order to convert
>>> image sizes from px to pt which at least I don't know. Mostly I can preset one size of
>>> a picture (say the width in pt) to be able to place it on a page and assuming
>>> x-resolution = y-resolution and keeping width-to-height ratio I calculate the missing
>>> size (here the height in pt) in Lua by
>>>
>>>                                                               picture-height-in-px
>>> asked-picture-height-in-pt = preset-picture-width-in-pt  *  --------------------
>>>                                                		    picture-width-in-px
>>>
>>> This is simple and normally it suffices for me.
>> Better use the built-in methods:
>>
>> \starttext
>>
>>      \getfiguredimensions[t:/sources/mill.png]
>>
>>      (\figurewidth,\figureheight)
>>
>>      (\figurexsize,\figureysize)
>>
>> \stoptext
>>
>> as it prevents opening the files multiple times. It's also more futureproof.
>>
>> Hans
>>
> 
> Hi Hans,
> 
> I fear it doesn't work. I used the above code with a test-picture of mine
> (in .png and .jpg version) and got:
> 
> (0sp,0sp)
> (0,0)
> 
> Now I'm baffled what the explanation could be. Are "mill" or "cow" somehow
> specially prepared? I used:
> 
> ConTeXt  ver: 2018.03.16 22:20 MKIV beta  fmt: 2018.3.21 and
> getfiguredimensions[~/my-test-picture.png]

maybe the image is not found ... what if you replace the ~



-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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-23 11:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19  9:48 Rudolf Bahr
2019-02-22  9:14 ` Rudolf Bahr
2019-02-22 11:59   ` Peter Münster
2019-02-23 10:08     ` Rudolf Bahr
2019-02-23 10:56       ` Hans Hagen
2019-02-23 11:37         ` Rudolf Bahr
2019-02-23 11:48           ` Hans Hagen [this message]
     [not found] <mailman.727.1550955497.1205.ntg-context@ntg.nl>
2019-02-23 22:38 ` Jeong Dal

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=15bcb709-2612-df32-c839-7eb06545fe5f@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    --cc=quasi@quasi.de \
    /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).