473,748 Members | 9,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Graphics: Get Dimensions of a frame in a multi frame tiff

I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase the
resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane
Nov 21 '05 #1
5 5995
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane

Nov 21 '05 #2
Actually, I did Bob, and with some success.

The problem is that, I seem to be able to take a TIFF (multi) and using your
encoding params, get it to single TIFF's with no problem.

The problem is getting it to the right kind of TIFF for our legacy VB6 app
to be able to display it, using LEAD tools 12.

Apparently I am doing something wrong, that it won't load it using the LEAD
control.

Are there other encoder params that I should consider? Where do we find
such things?

Also, while I am asking, is there a way to get the dimensions of a frame? H
x W? I know that in one of the things I tried, I was getting PNG's
proportionally correct, except with lots of black space to the right and
bottom of the image...this because I was trying to drawimage onto a new
bitmap that I was dimensioning using the Height and Width properties of the
Bitmap which I used to load the TIFF file.

I will take a look again at the methods you have, but if you can point me to
any encoder stuff that I might need to know about tiffs and pings, then I
would appreciate it.

Thanks,

Shane

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane


Nov 21 '05 #3
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4 encoder
param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffT oSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\tes tfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFla g
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo. GetImageEncoder s()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParamete r = New
EncoderParamete r(Encoder.Compr ession, CLng _
(EncoderValue.C ompressionCCITT 4))
Dim encParams As EncoderParamete rs = New EncoderParamete rs(1)
encParams.Param (0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile( strFilePath)

'if we have more than one page
If multi.GetFrameC ount(FrameDimen sion.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrame Count(FrameDime nsion.Page)) - 1
'get the current page in the TIFF
multi.SelectAct iveFrame(FrameD imension.Page, i)
multi.Save(Stri ng.Format("c:\s cratch\Page{0}. tiff", i),
info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Excepti on->: " & ex.Message, MsgBoxStyle.Inf ormation)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much larger
than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black space
surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane


Nov 21 '05 #4
Ahh, them third party tools really throw a spanner in the works sometimes.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4
encoder param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffT oSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\tes tfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFla g
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo. GetImageEncoder s()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParamete r = New
EncoderParamete r(Encoder.Compr ession, CLng _
(EncoderValue.C ompressionCCITT 4))
Dim encParams As EncoderParamete rs = New EncoderParamete rs(1)
encParams.Param (0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile( strFilePath)

'if we have more than one page
If multi.GetFrameC ount(FrameDimen sion.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrame Count(FrameDime nsion.Page)) - 1
'get the current page in the TIFF
multi.SelectAct iveFrame(FrameD imension.Page, i)
multi.Save(Stri ng.Format("c:\s cratch\Page{0}. tiff", i),
info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Excepti on->: " & ex.Message, MsgBoxStyle.Inf ormation)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much
larger than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black
space surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane



Nov 21 '05 #5
Yes, but that's what I'm stuck with until the rewrite. ;)

Thanks Bob!

Thanks for your site--and all the GDI+ articles you have written.

Shane
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eK******** *****@TK2MSFTNG P14.phx.gbl...
Ahh, them third party tools really throw a spanner in the works sometimes.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Ok, we got the right parameter. For anyone using LEAD12 in VB6 to read
single TIFF files, that were split form a multiframe TIFF using .NET, the
following code worked for us:

We got much of it from Bob Powell's site, but had to add the CCITT4
encoder param for LEAD Tools 12 to read it.

Private Sub SplitMultiTiffT oSingleTiffs()
Try
Const strFilePath As String = "c:\Scratch\tes tfax.TIFF"
'Select the image encoder
Dim enc As Encoder = Encoder.SaveFla g
Dim info As ImageCodecInfo = Nothing
Dim ice As ImageCodecInfo

For Each ice In ImageCodecInfo. GetImageEncoder s()
If ice.MimeType = "image/tiff" Then
info = ice
End If
Next ice

Dim MyEncorderParam As EncoderParamete r = New
EncoderParamete r(Encoder.Compr ession, CLng _
(EncoderValue.C ompressionCCITT 4))
Dim encParams As EncoderParamete rs = New EncoderParamete rs(1)
encParams.Param (0) = MyEncorderParam

'load the file
Dim multi As Image = Image.FromFile( strFilePath)

'if we have more than one page
If multi.GetFrameC ount(FrameDimen sion.Page) > 1 Then
Dim i As Integer
' 'loop through each page
For i = 0 To (multi.GetFrame Count(FrameDime nsion.Page)) -
1
'get the current page in the TIFF
multi.SelectAct iveFrame(FrameD imension.Page, i)
multi.Save(Stri ng.Format("c:\s cratch\Page{0}. tiff",
i), info, encParams)
Next i
End If
multi.Dispose()
Catch ex As Exception
MsgBox("Excepti on->: " & ex.Message, MsgBoxStyle.Inf ormation)
End Try
End Sub

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Take a look at the application that accompanies my article on how to add
pages to a multi-frame TIFF.

It's in the GDI+ FAQ. See the DoOpen method.

Code is in C# and VB.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Shane Story" <sh************ **@dv-corp.com> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
I can seem to get the dimensions of a frame in a multiframe tiff.

After selecting activeframe, the Width/Height is still really much
larger than the page's actual dimensions.

When I split a TIFF to several PNG files this causes a problem, becuase
the resulting image is (the page to the far left and a lot of black
space surrounding it and a filesize that is larger than needed.

Any ideas?

Any way to get the dimensions of this page/frame?

Thanks,

Shane



Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3933
by: Ruby Tuesday | last post by:
How do I find the information about an image, e.g. its dimension, whether it's jpg, tiff, bmp, gif, etc using the native PHP function? I know that we can do it by using the imagemagick, but perhaps some webhosting site does not have that installed. Thanks
1
2421
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the white background, which will turn to transparent. The most important thing here is that the TIFF image...
0
1150
by: Shane Liesegang | last post by:
I made a tiff file in Photoshop that contains multiple layers. When I read it back in to Photoshop, the layers show up all fine and happy, I'm trying to write a program that parses these layers in different ways, though, and having some trouble. The following code: Image image = Image.FromFile(filename); int temp = image.GetFrameCount(FrameDimension.Page); System.Console.Out.WriteLine(temp); outputs "1".
0
1051
by: familyman90 | last post by:
I have a query whose results contain the full path (i.e. c:\Images\xxx.tiff) to MUTI-PAGE TIFF documents. I need to figure out how to print all pages of the tiff's using the path from the query results as part of an Access report. I can use an image control on a report w/ single page tiff's but haven't figured out how to address the multi page tiff's.
2
4133
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this: http://www.pythonware.com/library/pil/handbook/introduction.htm but it looks like it is something I will need to install - I'd like to be able to pass my script around to people without them needing any
5
4065
by: Andy | last post by:
Hi, I am using the following code to render a text string in a new bitmap file. The code works, but the text looks, well, crappy, even though I told it to use ClearType hints. Any idea how to make the text look nicer? Thanks Andy
4
3987
by: Steve K. | last post by:
I would like to rotate pages in a multi-page tiff. Here is my first attempt: <code> public void RotatePageAndSave(int degrees) { RotateFlipType rotateType = RotateFlipType.Rotate180FlipNone; switch(degrees) { case 180: rotateType = RotateFlipType.Rotate180FlipNone; break;
0
2067
by: =?Utf-8?B?VmVuZWRpY3Q=?= | last post by:
Hi All, Knowing that .net 1.1 and .net 2.0 doesn't support due to GDI+. Does anyone know whether WPF can support the decoding of multi frame TIFF with JPEG compression? Thanks in advance.
8
3133
by: Abhiraj Chauhan | last post by:
I need someone to make an example of how to create a graphics window in VB.net 2008. I understand the basics of how to draw a rectangle and lines etc. What I need is an example of how to make a window that goes in a form that does the following: 1. When the application is run, the form has a graphics area within the form (not the entire form) colored white. 2. Two text boxes (not in the graphics area) for data entry used to define...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.