Specify format of large numbers when used in filenames

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
joelmalone
Posts: 2
Joined: 2013-10-23T18:31:45-07:00
Authentication code: 6789

Specify format of large numbers when used in filenames

Post by joelmalone »

Hello

I use the following script to tile large images into 256x256 chunks, with a tile X and Y in the filename, for use in Google Maps-style maps:

Code: Select all

convert input.png -sample 400% -crop 256x256 -set filename:tile "%[fx:page.x/256.0+1724074]_%[fx:page.y/256.0+1245486]" +repage +adjoin "%[filename:tile].png"
Basically, it resizes the image, cuts it up into 256x256 tiles, then writes the filenames out as "x_y.png". X and Y are calculated from the page x and y using expressions, then a large number is added to each, which positions it in the global map (i.e. the large numbers are necessary).

The problem is, the number can be quite large, so are being converted to string in "e" format, e.g. filenames come out as:

Code: Select all

1.72409e+006_1e+008.png
Which should rather be something like:

Code: Select all

12345678_12345678.png
Is there any way I can tell ImageMagick to format the numbers as plain numbers when converting them to a string?

Thanks

Joel
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Specify format of large numbers when used in filenames

Post by snibgo »

Try "-precision 10", or larger number. http://www.imagemagick.org/script/comma ... #precision
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Specify format of large numbers when used in filenames

Post by anthony »

At this time you can not specifically format any particalar number other than the 'scene' number.

I did have plans to allow nesting of %[...] expresions, and include a %[fmt:...] expression to format a number (or perhaps multiple numbers and strings) however it is becoming unlikely I will complete that task. :-(
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
joelmalone
Posts: 2
Joined: 2013-10-23T18:31:45-07:00
Authentication code: 6789

Re: Specify format of large numbers when used in filenames

Post by joelmalone »

Hi, sorry for the long delay in responding!

Snibgo, I added -precision 10 to the command, and it works perfectly. Thanks!

Anthony, luckily for my purposes I don't need any advanced formatting options, so the above suffices. However, thanks for your response and thanks for an excellent tool!

Joel
Post Reply