[Image-SIG] Generate .tif stack
Fredrik Lundh
fredrik at pythonware.com
Sat Aug 30 09:34:01 CEST 2008
assa sittner wrote:
> I would like to generate a series of synthetic images, and then wrap
> them all up into a single-file .tif stack (like in metamorph or ImageJ).
> how can i do that in python?
you can use PIL to create the individual frames, but PIL doesn't contain
any ready-made API for creating stacks; the simplest approach is
probably to write the frames to disk, and then use the external "tiffcp"
command to build the final file.
outline:
command = ["tiffcp"]
# add options here, if any (e.g. for compression)
for i in range(...):
im = Image.new(...)
...
framefile = "frame%d.tif" % i
im.save(framefile)
command.append(framefile)
command.append("stack.tif")
subprocess.call(command)
# remove frame files here
</F>
More information about the Image-SIG
mailing list