Extract some page from multi page TIFF file

VFP show from multi page tiff first page only. If you want extract some page to independently files, you can use class _XFRX_TIFF_WRITER.


This example is for XFRX 21.0.

Extract from first to second page, each page create new file 

LOCAL m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags, m.loTIFF
m.lcSource="input.tiff"         && Input file
m.lcDestination="output_.tiff"  && Output file
m.tnFrom=1                      && from page
m.tnTo=2                        && to page
m.tnAllEvenOdd=1                && even or odd or all pages
m.liFlags=0                     && 1 - Append to existing file, 2 - selected pages to one file

SET PROCEDURE TO xfrx.prg
m.loTIFF=CREATEOBJECT("_XFRX_TIFF_WRITER")
?m.loTIFF.ExtractPage(m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags)

Extract from first to second page, each page create new file, page will add to existing file

LOCAL m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags, m.loTIFF
m.lcSource="input.tiff"       && Input file
m.lcDestination="output.tiff" && Output file
m.tnFrom=1                    && from page
m.tnTo=2                      && to page
m.tnAllEvenOdd=1              && even or odd or all pages
m.liFlags=1                   && 1 - Append to existing file, 2 - selected pages to one file

SET PROCEDURE TO xfrx.prg
m.loTIFF=CREATEOBJECT("_XFRX_TIFF_WRITER")
?m.loTIFF.ExtractPage(m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags)

Extract  pages 5.,6.,7.,8. and 10, each page create new file 

LOCAL m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags, m.loTIFF
m.lcSource="input.tiff"         && Input file
m.lcDestination="output_.tiff"  && Output file
m.tnFrom="5-8,10"               && from page
m.tnTo=0                        && to page
m.tnAllEvenOdd=1                && even or odd or all pages
m.liFlags=0                     && 1 - Append to existing file, 2 - selected pages to one file

SET PROCEDURE TO xfrx.prg
m.loTIFF=CREATEOBJECT("_XFRX_TIFF_WRITER")
?m.loTIFF.ExtractPage(m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags)

Extract from first to second page, both pages will be in one new file 

Simply append mode.

LOCAL m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags, m.loTIFF
m.lcSource="input.tiff"       && Input file
m.lcDestination="output.tiff" && Output file
m.tnFrom=1                    && from page
m.tnTo=2                      && to page
m.tnAllEvenOdd=1              && even or odd or all pages
m.liFlags=2                   && 1 - Append to existing file, 2 - selected pages to one file

SET PROCEDURE TO xfrx.prg
m.loTIFF=CREATEOBJECT("_XFRX_TIFF_WRITER")
?m.loTIFF.ExtractPage(m.lcSource, m.lcDestination, m.tnFrom, m.tnTo, m.tnAllEvenOdd, m.liFlags)