ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Rudolf Bahr <quasi@quasi.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: When newsizing an external figure bei [width=<some pt>], what will be its height in pt and viceversa?
Date: Fri, 22 Feb 2019 10:14:15 +0100	[thread overview]
Message-ID: <20190222091414.kehdxqfkhdktdbju@nan> (raw)
In-Reply-To: <20190219094838.rb772tdgj6iiv6cd@nan>

On Tue, Feb 19, 2019 at 10:48:38AM +0100, Bahr Rudolf wrote:
> Hi All,
> 
> from an external figure I normally know its width and height in px. 
> But I don't know its exact sizes in pt. When newsizing the figure 
> in a document (by the same width-to-height-ratio), I'll do that as 
> some part of textwidth or textheight, in pt or mm, but not in px, 
> i.e. by means of [width=<some pt>]. 
> Sometimes it would be interesting to know its new height in pt, 
> and viceversa. 
> 
> Is there a variable or something else containing its new size in pt?
> 
> Regards,
> Rudolf




Hi All,

up to now Nobody answered to my question, perhaps it might have been
too simple.

Indeed One could normally assume:


picture-width-in-px      preset-picture-width-in-pt
--------------------  =  --------------------------
picture-height-in-px     asked-picture-height-in-pt


And according to Adam Riese One gets:

                             preset-picture-width-in-pt  *  picture-height-in-px
asked-picture-height-in-pt = ---------------------------------------------------
                                             picture-width-in-px


-----------------
The picture sizes in px One gets by invoking for instance graphics Magick's identify
in a lua program:

local file = assert ( io.popen ( 'gm identify ' .. picture_name, 'r' ))
local output = file:read ( '*all' )
file:close ()

local words = {}
for w in string.gmatch ( output, "%g+" ) do
    words [ #words + 1 ] = w
end

-- Width and height are found in words[3]: i.e. 5407x3544+0+0
local dims = {}
for d in string.gmatch ( words [ 3 ], "%d+" ) do
    dims [ #dims + 1 ] = d
end

local px_width  = dims [ 1 ]
local px_height = dims [ 2 ]
-----------------

It's a solution at least as long as your Lua supports "io.popen". There might be
shorter solutions.

Cheers, Rudolf

 
___________________________________________________________________________________
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-22  9:14 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 [this message]
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
     [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=20190222091414.kehdxqfkhdktdbju@nan \
    --to=quasi@quasi.de \
    --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).