Create Tiff Image

Good afternoon Experts!

OK, so I need to create a TIFF Image...BUT it needs to be in the same compression as another TIFF Image I have from a system I'm using.  I want to create my own TIFF Images for this system...but the ones I've created using 2005 have not been in the same format as the ones on this system.

So my question is how can I determine what compression the TIFF file is I have so I can try to replicate it in the same format.

Who is Participating?
Joe Winograd - EE Fellow & MVEConnect With a Mentor DeveloperCommented:
Great...glad to hear that worked!

IrfanView lets you combine multiple TIFFs into a single, multi-page TIFF, but it does not give you control over the offsets. The syntax to combine multiple TIFFs is to put as many file names as you want after the first file name (which is the output file). For example:

i_view32.exe /multitif=(out.tif,in1.tif,in2.tif,in3.tif) /killmesoftly /silent /tifc=4

Also, it supports wildcards:

i_view32.exe /multitif=(out.tif,in*.tif) /killmesoftly /silent /tifc=4

And you can do both at once (multiple files and wildcards):

i_view32.exe /multitif=(out.tif,in1.tif,source*.tif,in2.tif) /killmesoftly /silent /tifc=4

We had a thread a few months ago where the asker wanted to combine multiple TIFFs into a single TIFF based on a starting position number (aka an offset) and a length. Perhaps you'll find it helpful:

Regards, Joe
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
If you open it in Irfanview ( ) and press I, an information window will pop up and tell you what compression is being used.
Joe Winograd - EE Fellow & MVEDeveloperCommented:
Hi Mark,
I have this C# code in my files from a few years ago (it should not be difficult for you to convert it to VB.Net):
public static int GetCompressionType(Image image)
  int compressionTagIndex = Array.IndexOf(image.PropertyIdList, 0x103);
  PropertyItem compressionTag = image.PropertyItems[compressionTagIndex];
  return BitConverter.ToInt16(compressionTag.Value, 0);

Open in new window

I normally like to attribute sources, but in this case I don't show it in my records. The return value is supposed to be the compression method, but you should check this through some experimentation:

3=ITU-T (formerly CCITT) Group 3
4=ITU-T (formerly CCITT) Group 4

To test the above, you can use IrfanView (free) to create TIFF files with various compression:

The IrfanView GUI gives you a dialog box where you have a radio button to select compression, while the IrfanView command line (i_view32.exe) has this option:


where N is defined as:

3=ITU-T (formerly CCITT) Group 3
4=ITU-T (formerly CCITT) Group 4

Also, the IrfanView GUI will show the TIFF compression via the Image menu then Information (or the blue circle "i" icon on the toolbar):

IrfanView showing TIFF compressionRegards, Joe
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

smithmrkAuthor Commented:

OK, It was created in CCITT Group 4 Fax Encoding, how can I create images in in this same format?

Joe Winograd - EE Fellow & MVEDeveloperCommented:
Well, an easy way to do it is run the command line IrfanView with the "/tifc=4" parameter from your VB.Net program. The IrfanView call would be something like this:

i_view32.exe /multitif=(convertedG4.tif,input.tif) /killmesoftly /silent /tifc=4

The command line syntax, with all of the options and many examples, is in a plain text file called <i_options.txt> that is placed in the installation folder. Btw, IrfanView does not have to be "installed" to run it. Of course, it doesn't hurt to do a standard install (which will put the files in <Program Files> or <Program Files (x86)>), but all that you need for the command line to work is access to <i_view32.exe> and <i_view32.ini> (the latter is IrfanView's configuration file).

If you'd like to see a call to IrfanView with the "/tifc" parameter from a program (although not VB.Net), take a look at this article:

It's a long article and a somewhat large program, but you can focus just on the RunWait call to IrfanView. Regards, Joe
Dave BaldwinFixer of ProblemsCommented:
You need to check your own images.  There are at least 8 different compression methods shown in Irfanview when you do a "Save As" to TIFF.
smithmrkAuthor Commented:
Seems like a lot of there any way I can take this code shown here and save it as that Compression Type?

'Image Information:
        Dim ImgOffset As Int32 = 0
        Dim ImgLength As Int32 = 0
        Dim ImgResolution As Int32 = 200
        Dim ImgHeight As Int32 = 574
        Dim ImgWidth As Int32 = 1312

        Dim ImageWriter As IO.FileStream = New IO.FileStream("C:\TestImage.tif", FileMode.Create)
        Dim memstrm As IO.MemoryStream = New IO.MemoryStream
        Dim ticket As New Bitmap(ImgWidth, ImgHeight)

        Dim BatchID_Font As New Font("Arial", 20, FontStyle.Regular)
        Dim BatchAuthor_Font As New Font("Arial", 15, FontStyle.Regular)

        Dim ticketGraphics As Graphics = Graphics.FromImage(ticket)
        ticketGraphics.FillRectangle(Brushes.White, 0, 0, ImgWidth, ImgHeight)
        ticket.SetResolution(ImgResolution, ImgResolution)

        ticketGraphics.DrawString("-- My Ticket --", BatchID_Font, Brushes.Black, 520, 90)
        ticketGraphics.DrawString("Ticket ID: 800001", BatchID_Font, Brushes.Black, 10, 160)
        ticketGraphics.DrawString("Ticket Amount: 111", BatchID_Font, Brushes.Black, 10, 200)
        ticketGraphics.DrawString("Date: " & Now().ToShortDateString, BatchID_Font, Brushes.Black, 10, 240)

        ticket.Save(memstrm, System.Drawing.Imaging.ImageFormat.Tiff)
        ImgLength = memstrm.Length

Joe Winograd - EE Fellow & MVEDeveloperCommented:
> There are at least 8 different compression methods shown in Irfanview when you do a "Save As" to TIFF.

Yes, those 8 compression methods are described in post <http:#a40021165> above for the command line call (/tifc=0 through /tifc=7). For the GUI, the 8 methods are chosen with radio buttons like this:

IrfanView GUI showing TIFF compressionRegards, Joe
smithmrkAuthor Commented:
Thanks but I don't want to use different program I want to create my own images in CCITT Group 4 Format out of my own program.

Dave BaldwinFixer of ProblemsCommented:
I was just asking if you had checked your own images.
Joe Winograd - EE Fellow & MVEDeveloperCommented:
> Seems like a lot of work

It should be just one line of code...maybe a few if VB.Net needs some kind of setup to run an EXE. I don't code in VB.Net, but there must be a way to run an EXE file, so it should be something like this: i_view32.exe /multitif=(convertedG4.tif,input.tif) /killmesoftly /silent /tifc=4

Since I don't know VB.Net, I can't help with the code you posted. I'm sure Dave can (he's a real expert in .NET) or maybe someone else will jump in to look at your code. Regards, Joe
smithmrkAuthor Commented:
What I meant by it being a lot of work is that I don't want a 3rd party application (I_View32.exe) to have to be installed on the users machine.

I found this by I get Paramater Not Valid error can someone tell me why I get that when I select the CompressionCCITT4?

Joe Winograd - EE Fellow & MVEDeveloperCommented:
Here's the VB link showing the choices for EncoderValue:

It says that the one you're looking for is:


If that's not working, I don't know why.

Btw, you do not have to install IrfanView on the user's machine. Put it on a server...wherever you're putting your program...all you have to do is put <i_view32.exe> and <i_view32.ini> in the same folder as your program.

I need to leave my office now for a couple of hours. I'll check back into this thread to see how you're doing as soon as I return. Regards, Joe
smithmrkAuthor Commented:
OK, this worked...
i_view32.exe /multitif=(convertedG4.tif,input.tif) /killmesoftly /silent /tifc=4

Now I have a NEW Problem!
I need to merge several images into one TIFF File, how can I do that?

You see I'm creating these images with my program vitural tickets...once done I need them in one file with offsets.

For example:
File = MyImageFile.tif

1st Image = offset 0 size = 1459
2nd Image = offset 1459 size 1536
3rd Image = offset 2995 size 1544
4th Image = offset 4539 size 1389

Because the receiving application of this TIFF Image File is looking to pick up these images within this one file based on the offset and size of the image.

smithmrkAuthor Commented:
Thanks Guys!

Joe that link to the other issue someone was having REALLY HELPED!!!!

Joe Winograd - EE Fellow & MVEDeveloperCommented:
You're very welcome. That is certainly a brilliant piece of code that kaufmed wrote and I'm glad that it helped you. Regards, Joe
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.