2007-11-03

How to Extract frames from MultiPage TIFFs

here's the link of a utmag article that covers the tiff subject deeply:
tiff and the new gdiplusx classes



at the topic "extracting frames from tiffs" you'll find the code below, that saves the frames of a tiff in separate image files:

** howto: extract frames from a multiframe tiff

do locfile("system,prg")

with _screen.system.drawing

* load the multiframe tiff to gdi+
local lomultif as xfcbitmap
lomultif = .bitmap.new(getpict("tif"))
local lnframes, n, lcframefilename
lnframes = lomultif.getframecount()
if lnframes > 1
for n = 0 to lnframes - 1
lomultif.selectactiveframe(.imaging.framedimension.page, n)
lcframefilename = "c:\frame" + transform(n + 1) + ".tif"
lomultif.save(lcframefilename, .imaging.imageformat.bmp)
endfor
else
messagebox("the selected file is not a multiframe tiff")
endif

endwith
return

No comments:

Post a Comment