Scientific to decimal?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
RedFlyer
Posts: 8
Joined: 2014-01-30T16:57:55-07:00
Authentication code: 6789

Scientific to decimal?

Post by RedFlyer »

I'm using

Code: Select all

identify -format "%[fx:w*h]" filename
to get the total pixels of an image, but when the number gets to big IM spits it out in scientific notation.
Is there any way to get it to only use decimals for the output?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scientific to decimal?

Post by snibgo »

Code: Select all

identify -ping -precision 12 -format "%[fx:w*h]" vbig.png
This will help only up to a certain limit.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Scientific to decimal?

Post by fmw42 »

I think the max for -precision is 15

If on Linux/Mac and you need a bigger number than that, then use bc

ww=`identify -ping "%w" image`
hh=`identify -ping "%h" image`
echo "$ww*$hh" | bc`

There is likely something similar in Windows, but I do not know. One of the Windows users may be help on that.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Scientific to decimal?

Post by snibgo »

The Windows "set /A" is integers only, up to 2e10. Where necessary I use my own indefinite precision calculator.
snibgo's IM pages: im.snibgo.com
RedFlyer
Posts: 8
Joined: 2014-01-30T16:57:55-07:00
Authentication code: 6789

Re: Scientific to decimal?

Post by RedFlyer »

Fantastic, thank you so much.
Post Reply