Page 1 of 1
converting non fixed size images into a tilesheet
Posted: 2014-03-09T13:15:48-07:00
by stowelly
Hi, I bought some assets for a game im making, and it was stated suitible for tilemapping, and sorted into folders of the same images for different sizes, 64 x64 128x128 etc etc. but the images arent all aligned / trimmed to hard 128x128 so obviously creating a tilemap out of these is problematic. (varying combinations of larger / smaller on the x and y)
I have tried creating a montage with geometry 128x128 but it seems to do some kind of scaling on some of the images. and tried montage with a crop, which seemed to be a step in the right direction but it doesnt seem to pad the tiles correctly so that they are left alligned or right alligned depending on where it was cropped from.
then i tried to just try cropping the images individually before making a tilemap, but i couldnt turn one image that is say 173 x 214 into 4 128 x 128 images correctly aligned. I have been through the imagemagick docs quite a bit prior to posting here, but as an absolute noob to it, i feel i just dont understand enough to know exactly what each combination of params does.
thanks
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T13:33:26-07:00
by snibgo
If an image x.png is suitable for tiling then ...
Code: Select all
convert -size 600x400 tile:x.png r.png
should look good, without showing the joins.
If the originals are slightly over 128x128 or whatever, but still tile well, then you can probably resize them:
Code: Select all
convert x.png -resize 128x128! xRes.png
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T13:47:38-07:00
by stowelly
sorry i probably wasnt very clear.
the images fit perfectly together if you use them in photoshop or suchlike to align them, so resizing would mess up how they sit together / look
ill link the tileset i bought (cant legally post the actual files)
http://2.s3.envato.com/files/67100554/t ... Assets.jpg
you see the image at the bottom shows how the individual files are varied in size
so that big castle door is say 173 x 214 but the grass might be 128 x 30. and i need to pad these out and align them so that they all fit nicely together
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T13:54:25-07:00
by fmw42
If you just want to stack the images vertically, and they are all the same size, then use -append. See
http://www.imagemagick.org/Usage/layers/#append
Code: Select all
convert image1 image2 ... imageN -append result
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T14:00:15-07:00
by stowelly
thanks for your reply, but they are not the same size, which is the problem. ideally id like to know how I can crop them to the right size, but also pad out the cropped bits into equally sized tiles with the parts aligned at the point that they would meet each other in an array
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T14:09:28-07:00
by fmw42
I am not sure I follow. Can you provide a diagram of what you want to do or an example?
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T14:17:34-07:00
by stowelly
excuse the crap paint drawing (plus the yellow box seems barely visible)
but hope that makes it somewhat clearer..... its hard to show you without actually posting the assets....
http://stowelly.co.uk/paint.jpg
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-09T14:38:57-07:00
by fmw42
I am not sure I follow and should not the bottom images have height of 173. Nevertheless, try the following and let me know if that does what you want.
Code: Select all
convert image \
\( -clone 0 -crop 32x128+0+0 -background white -gravity east -extent 128x173 +repage \) \
\( -clone 0 -crop 96x100%+33+0 -background white -gravity west -extent 128x173 +repage \) \
-delete 0 +adjoin result
see
http://www.imagemagick.org/Usage/crop/#crop
http://www.imagemagick.org/Usage/crop/#extent
Re: converting non fixed size images into a tilesheet
Posted: 2014-03-10T06:45:35-07:00
by stowelly
I have sent you a pm with some sample assets attached. hopefully that will make it clear what i am trying to do
cheers