Page 1 of 1

Specify format of large numbers when used in filenames

Posted: 2013-10-23T18:45:51-07:00
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

Re: Specify format of large numbers when used in filenames

Posted: 2013-10-23T19:27:44-07:00
by snibgo
Try "-precision 10", or larger number. http://www.imagemagick.org/script/comma ... #precision

Re: Specify format of large numbers when used in filenames

Posted: 2013-10-28T17:21:35-07:00
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. :-(

Re: Specify format of large numbers when used in filenames

Posted: 2013-11-05T18:21:00-07:00
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