Page 1 of 1
Complex numbering: create simple column/row pattern
Posted: 2015-01-31T07:47:50-07:00
by honeybee
Hi everybody,
I have a series of smaller images from which I'm trying to build a larger one. I fiddled around quite a bit, but I'm not really getting it. I'm fighting with spacings, parameters in general and the biggest problem is probably the numbering of the tiles.
I try to explain what I'm intending to do:
I have 140 jpg's numbered from 0_[0-9].jpg to 13_[0-9].jpg. ImageMagick should put those images into 14 columns with 10 rows each, sewing them together seamlessly (like a photo) and with no loss of quality. For better visualization of this pattern I attached a picture.
I tried things like this. It's coming close, but misses pictures, parameters and of course it's only dealing with one row:
Code: Select all
montage [0-9]_1.jpg -tile 13x10 test.jpg
I need to create about a hundred of those "puzzles" and it's very important to me. If anyone has a good idea how to accomplish that I'd be more than thankful.
Regards
honeybee
Edit: I'm sorry, I'm using the latest version of ImageMagick (6.9.0-1 I guess?) on Win XP. The tiles are about 20kb and 256x256 px each with slight variations, but will come out as a perfect whole when stitched together.

Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T08:15:22-07:00
by snibgo
You can probably do this neatly with montage, but I'm not familiar with montage.
I'd do it something like this (untested):
Code: Select all
setlocal enabledelayedexpansion
set ALL_ROWS=convert
for /l %%y in (0,1,9) do (
set ONE_ROW=convert
for /l %%x in (0,1,13) do (
echo %%x_%%y
set ONE_ROW=!ONE_ROW! %%x_%%y.jpg
)
echo !ONE_ROW!
!ONE_ROW! +append ROW_%%y.png
set ALL_ROWS=!ALL_ROWS! ROW_%%y.png
)
echo !ALL_ROWS! -append allrows.png
!ALL_ROWS! -append allrows.png
The "echos" aren't needed, but are helpful for debugging.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T08:35:47-07:00
by honeybee
Oh snibgo, that was quick! It works perfectly. Thanks soo much.
Best regards
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T09:40:59-07:00
by honeybee
I'm sorry, is it possible to give the output file a dynamic name (folder name would be great) instead of a static (here "allrows")?
Say, the files are in (sub)folder "xyz". Is it possible to have the output file named xyz.png? Thank you.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T10:26:11-07:00
by snibgo
Well, that's just about the scripting. Put this near the top:
set FOLDER=xyz
Then refer to %FOLDER%\%%x_%%y.jpg
The output file would be %FOLDER%.png
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T11:34:55-07:00
by honeybee
Ok, thank you. I will try that. But will this name the files differently according to their specific folder names or will the name be what is specified in the top of the script (here xyz)?
It's because my tile sets are in various numbered folders which have names like 364, 865, 1112 and so on. I'd like to copy my standard batch file to each of those folders and start it from there without having to edit it every time (in this case I could rename the output file manually as well and probably easier).
It's not the biggest deal, but as I said, I have quite a lot of tile sets and they will become more (ongoing project), so every automated step would be a labor-saver. Thank you.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T12:13:20-07:00
by fmw42
I have 140 jpg's numbered from 0_[0-9].jpg to 13_[0-9].jpg. ImageMagick should put those images into 14 columns with 10 rows each, sewing them together seamlessly (like a photo) and with no loss of quality. For better visualization of this pattern I attached a picture.
I believe you would need to rename your images with leading zeros for the first numer as 00_[0-9] to 13_[0-9]. Then you could just do
montage *.jpg -tile 13x10 test.jpg
You of course would need to specify the offset (-geometry) and other montage arguments as desired.
However, montage reads all images into memory and so you may be running out of RAM. Working by append first in rows then in columns may be a better approach if memory is the issue.
You could easily get the folder name using the OS and put that into a variable that could be used for the output name.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T13:04:10-07:00
by honeybee
Thanks for the explanation. For now I'll be using snibgo's script. It's doing what I want and I'm really happy with it. ImageMagick is a powerful tool though and it might be that I want to use it in future projects as well.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T17:29:04-07:00
by snibgo
honeybee wrote:Ok, thank you. I will try that. But will this name the files differently according to their specific folder names or will the name be what is specified in the top of the script (here xyz)?
It's because my tile sets are in various numbered folders which have names like 364, 865, 1112 and so on. I'd like to copy my standard batch file to each of those folders and start it from there without having to edit it every time (in this case I could rename the output file manually as well and probably easier).
Again, this is just a scripting issue and nothing to do with ImageMagick.
Re: Complex numbering: create simple column/row pattern
Posted: 2015-01-31T17:34:57-07:00
by honeybee
Ok, thanks and sorry. I will try and see if I can find a way

Best