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 VB.net 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.

Thanks,
Mark
smithmrkAsked:
Who is Participating?
 
Joe Winograd, Fellow&MVEDeveloperCommented:
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:

http://www.experts-exchange.com/Software/Misc/Q_28332667.html

Regards, Joe
0
 
Dave BaldwinFixer of ProblemsCommented:
If you open it in Irfanview ( http://www.irfanview.com/ ) and press I, an information window will pop up and tell you what compression is being used.
0
 
Joe Winograd, 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:

1=None
2=Huffman
3=ITU-T (formerly CCITT) Group 3
4=ITU-T (formerly CCITT) Group 4
5=LZW

To test the above, you can use IrfanView (free) to create TIFF files with various compression:
http://www.irfanview.com/

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:

/tifc=N

where N is defined as:

0=None
1=LZW
2=Packbits
3=ITU-T (formerly CCITT) Group 3
4=ITU-T (formerly CCITT) Group 4
5=Huffman
6=JPG
7=ZIP

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
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
smithmrkAuthor Commented:
AWESOME!!!!

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

Thanks,
Mark
0
 
Joe Winograd, 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:
http://www.experts-exchange.com/Web_Development/Document_Imaging/A_10745-How-To-Combine-Merge-Append-TIFF-Files-in-Batch-Mode.html

It's a long article and a somewhat large program, but you can focus just on the RunWait call to IrfanView. Regards, Joe
0
 
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.
0
 
smithmrkAuthor Commented:
Seems like a lot of work...is 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)

        'Fonts:
        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)
        memstrm.WriteTo(ImageWriter)
        ImgLength = memstrm.Length

        ticket.Dispose()
        Logo.Dispose()
        memstrm.Close()
        memstrm.Dispose()
0
 
Joe Winograd, 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
0
 
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.

Mark
0
 
Dave BaldwinFixer of ProblemsCommented:
I was just asking if you had checked your own images.
0
 
Joe Winograd, 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:

whatever.calls.an.EXE.in.VB.Net 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
0
 
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?

http://msdn.microsoft.com/en-us/library/system.drawing.imaging.encoder.compression(v=vs.80).aspx

Thanks,
Mark
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Mark,
Here's the VB link showing the choices for EncoderValue:
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.encodervalue%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

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

CompressionCCITT4

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
0
 
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
etc...

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.

Thanks,
Mark
0
 
smithmrkAuthor Commented:
Thanks Guys!

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

Thanks,
Mark
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Mark,
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
0
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.