adjust-dpi.sh rounding problem
Chris Good
chris.good at ozemail.com.au
Mon Aug 15 05:57:15 EDT 2016
From: Chris Good [mailto:chris.good at ozemail.com.au]
Sent: Monday, 15 August 2016 1:11 PM
To: 'Geert Janssens' <geert.gnucash at kobaltwit.be>
Cc: 'gnucash-devel at gnucash.org' <gnucash-devel at gnucash.org>
Subject: adjust-dpi.sh rounding problem
Hi Geert,
There's a couple of problems with gnucash-docs/util/adjust-dpi.sh on Ubuntu
16.04 which makes it update (almost?) every image file each time it runs.
1. The identify utility in imagemagick Version: 8:6.8.9.9-7ubuntu5.1 returns
an unrounded dpi. E.g
existing_dpi=$(identify -format "%x" "$figure")
echo $existing_dpi
35.429999999999999716
2. It seems this script expects $existing_dpi to be suffixed with
(space)PixelsPerCentimeter but this doesn't happen for me.
I was thinking of fixing these problems by using something like:
existing_dpi=$(identify -format "%x" "$figure")
existing_dpi=${existing_dpi% PixelsPerCentimeter} #
strip possible trailing (space)PixelsPerCentimeter
existing_dpi=$( printf '%.2f' "$existing_dpi" )
# round to 2 decimals
I guess there is a way to do this all on 1 line but I'd have to do some
research and I prefer KISS principle anyway.
Is this portable enough?
Regards,
Chris Good
I decided to use awk printf to do rounding and drop suffix in 1 step.
I fixed the script, including a couple of other rounding problems caused by
Ubuntu identify, and code duplication.
I'll do a bug + pull request as soon as I can commit what I'm currently
working on.
Regards, Chris Good
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4817 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20160815/65fd744a/attachment.p7s>
More information about the gnucash-devel
mailing list