2007-11-03

How to Extract frames from MultiPage TIFFs

Here's the link of a UTMAG article that covers the tiff subject deeply:
TIFFs 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