converting non fixed size images into a tilesheet

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
stowelly
Posts: 5
Joined: 2014-03-09T12:24:22-07:00
Authentication code: 6789

converting non fixed size images into a tilesheet

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: converting non fixed size images into a tilesheet

Post 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
snibgo's IM pages: im.snibgo.com
stowelly
Posts: 5
Joined: 2014-03-09T12:24:22-07:00
Authentication code: 6789

Re: converting non fixed size images into a tilesheet

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: converting non fixed size images into a tilesheet

Post 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
stowelly
Posts: 5
Joined: 2014-03-09T12:24:22-07:00
Authentication code: 6789

Re: converting non fixed size images into a tilesheet

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: converting non fixed size images into a tilesheet

Post by fmw42 »

I am not sure I follow. Can you provide a diagram of what you want to do or an example?
stowelly
Posts: 5
Joined: 2014-03-09T12:24:22-07:00
Authentication code: 6789

Re: converting non fixed size images into a tilesheet

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: converting non fixed size images into a tilesheet

Post 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
stowelly
Posts: 5
Joined: 2014-03-09T12:24:22-07:00
Authentication code: 6789

Re: converting non fixed size images into a tilesheet

Post 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
Post Reply