[Image-SIG] Generate .tif stack

Sebastian Haase haase at msg.ucsf.edu
Sat Aug 30 10:56:45 CEST 2008


Hi Assa, Fredrik,
I submitted a patch to this list some time ago that allows creating
this kind of "multi page" TIFF files.  Could this get applied to the
trunk PIL version !?

Regards,
Sebastian Haase


On Sat, Aug 30, 2008 at 9:34 AM, Fredrik Lundh <fredrik at pythonware.com> wrote:
> 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>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list