I want to make a little tool for creating tilemaps from a series of images. Such as : http://i.imgur.com/Q1OQM.png for instance.
My tool will simply get the size of each images, check they are all the same, and fit them all, aligned, into a bigger image².
I want to do this tool in Python to start learning it a bit more, it seem to me fairly simple enough, perfect for starting slowly.
Python would maybe not the best choice to do this tool, but I already have some Maxscript experience and Python is the next thing I want to learn (And I really really want to do this tool).
Arg don’t spoil me like this ! I just wanted advises on where to find the code I need. Not the code itself . In max I know where to look for it, in the Maxscript reference. For python… well I havn’t really find one equivalent.
I have first found this : The Python Standard Library — Python 3.12.6 documentation but havnt found anything in there usefull for me (or I don’t know how to use it.) Then I have found this : http://effbot.org/imagingbook/overview.htm which seems to go in the direction I want.
Actually I would be very interested to know where you get this code you pasted here, the “where” is exactly what I am looking for.
i also know python quite well…
one of the python scripts that i made was to crop image…
so some of the code is from that…
and since you know you are going to use Image from PIL in python it’s quite easy to see the commands…
open python
from PIL import Image
help(Image)
# help(Image.new)
that will show you what you can do with the Image module… and you can start from there
Hi, wonderfull ! thanks, that’s what I’m looking for I wasnt sure about PIL (there was maybe something else better ? This is quite new for me). Looks like I have all I need now (and more!)
Thanks very much !
Bloby.
Im working on a similar tool doing this with renderend out frames from maya dynamics. What im still trying to figure out is the best way to have the code layout the images into a grid, and what scale factor has to be used in cases where they wont all fit.
Anyone got insight on this?
Knowen info would be the final image res, and the res for the input images, and how many images…
What about the series of image give you the final image size (so no scale factor) ? That’s what I will do actually.
Using the surface of each images.
Getting the number of pixel for all of the images (width * height * number of images), I get the square root to get a square capable of containing this total surface of my images and I roundup to the next power of two above.
if I have 21 images of 3264
the surface give me 213264= 43008
the square root of 43008 give me 207 and bananas.
If I roundup to the next power of two I get 256256.
Only problem I get only squares, and depending on my series of images, in some cases, I could end up using only half of the map. So it will need another step after to get the blank space, how many lines the tool did on the square, and somehow get a ratio out of that to make the map longer while croping the height, while keeping a power of 2. something like that.
I don’t know yet how I will be doing my rounding : ) I have just thinking to the theory and gather references, framework ready for my next Pizza/Code weekend : ) Haven’t look in details yet : )
Have you figured out a way to work with non square textures yet?
I was experimenting a bit with the Photoshop api, and got something similar working with the squarert method, but this is very limiting since both my input textures and the final texture must be square.
[QUOTE=passerby;24628]Have you figured out a way to work with non square textures yet?
I was experimenting a bit with the Photoshop api, and got something similar working with the squarert method, but this is very limiting since both my input textures and the final texture must be square.[/QUOTE]
Havent started yet No time outside the weekend.
With “my” methode input textures dont have to be square, only the output will. I am sure there is some way to then optimize that by looking at the free space on the texture and the nulber of “row” but I am not here yet.