1

On client side I have image in TIFF images with multiple pages.

Firt I convert this image file to byte array and then I sent this data to web service.

For converting TIFF to byte array I use method System.IO.File.ReadAllBytes.

On web service side I would like convert this byte array to If byte array contains invalid data it will be nice to have som control.

Then I need do these things:

  • parse all pages from multi TIFF image to objects type of System.Drawing.Image

  • get specified images from multi TIFF

  • convert BitMiracle.LibTiff.Classic.Tiff object to byte array

  • save BitMiracle.LibTiff.Classic.Tiff object to disk in TIFF format

I google it, tried many samples but for me is bit problem convert byte array to BitMiracle.LibTiff.Classic.Tiff (and back) and convert BitMiracle.LibTiff.Classic.Tiffobject which hold multi TIFF to collection of System.Drawing.Image.

kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
whyme
  • 51
  • 3
  • 9

1 Answers1

1

There are two samples that show how to create System.Drawing.Image from a TIFF

These samples create System.Drawing.Image for the current page of a TIFF. By default, current page is the first page.

In case your TIFF image is multipage you still can use the code from samples. But you will need to encapsulate the code in a method and call that method multiple times: one time for each page.

The number of pages can be retrieved using NumberOfDirectories method. Current page can be set using SetDirectory method.

The How to use a System.IO.Stream to read or write TIFF images sample shows how to read TIFF image from a memory stream.

Bobrovsky
  • 13,789
  • 19
  • 80
  • 130
  • Great. But one question LibTiff.NEt doesnt have method which parse all pages from multi tiff do another collection? I must parse one by one? – whyme Aug 25 '12 at 19:07
  • @whyme Honestly, I am not sure if I understand you right. Do you want to create multipage TIFF from multipage TIFF? Or what? – Bobrovsky Aug 25 '12 at 19:18
  • No, first I load multi page TIFF to BitMiracle.LibTiff.Classic.Tiff object and then I need parse all pages from this object to List – whyme Aug 26 '12 at 13:27
  • Ok, as I told in the answer, you will need to adapt existing samples and parse pages one by one. – Bobrovsky Aug 26 '12 at 13:37