Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Stefan  
#1 Posted : Sunday, May 28, 2006 4:20:33 PM(UTC)
Stefan

Rank: Member

Groups: Member
Joined: 5/27/2006(UTC)
Posts: 2

Hi,

I've got a problem with GraphicsMill 2.0.399.0 and TIFF-Files saved in Photoshop with a resolution of 140 Pixel per cm:

With BitmapViewer1.Bitmap.HorizontalResolution GraphicsMill gives back 140 instead of 355.6!

Is it possible to find out which unit (pixel per inch/pixel per cm) was used to save the file to calculate the resolution in pixel per inch?
Andrew  
#2 Posted : Monday, May 29, 2006 2:44:02 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
There is a known bug in Graphics Mill - it interprets resolution solely in dots per inches. If you save it in dots per centimeters, resolution will be calculated incorrectly.

Unfortunately there is no workaround for this problem in Graphics Mill.
Stefan  
#3 Posted : Wednesday, June 7, 2006 12:45:21 AM(UTC)
Stefan

Rank: Member

Groups: Member
Joined: 5/27/2006(UTC)
Posts: 2

Hi Andrew,

here is a workaround I wrote in Visual Basic to get the ResolutionUnit of a Tiff-File. So it's easy to calculate the correct Resolution. The function gives back 1 (No absolute unit of measurement), 2 (Inch) or 3 (Centimeter). In case of an error or if the file is no valid Tiff-File, it gives back 0.

Code:
Enum TiffResolutionUnit
    NoUnit 'Failed or file is no Tiff
    NoAbsolutUnit
    Inch
    Centimeter
End Enum


Public Function getTiffResolution(sFile As String) As TiffResolutionUnit

Dim fFormat As String
Dim Data2 As Integer
Dim Data4 As Long
Dim FN As Integer
Dim i As Integer
Dim buffer() As Byte
Dim resString As String

getTiffResolution = NoUnit

  FN = FreeFile
  
  Open sFile For Binary Access Read As FN
  
  fFormat = Space$(2)

    Get FN, , fFormat
    
    ReDim buffer(1)
    
    Get FN, , buffer
    Data2 = buffer(0) + buffer(1) ' 42 = tiff
    If Data2 <> 42 Then
        Exit Function
    End If
    
    ReDim buffer(3)
        
    Get FN, , buffer 'First IFD
    Data4 = buffer(0) + buffer(1) + buffer(2) + buffer(3)
        
    Seek FN, Data4 + 1 'Goto first IFD
    ReDim buffer(1)
    
    Get FN, , buffer
    Data2 = buffer(0) + buffer(1)  'IFD Entries
    
    For i = 1 To Data2
    ReDim buffer(11)
    Get FN, , buffer
    If fFormat = "II" Then
    resString = Hex(buffer(1)) & Hex(buffer(0))
    Else
    resString = Hex(buffer(0)) & Hex(buffer(1))
    End If
        If resString = "128" Then
        getTiffResolution = buffer(8) + buffer(9) + buffer(10) + buffer(11)
        Exit For
        End If
    Next
    
  Close FN

End Function



By the way: On page 27 of TIFF Revision 6.0 you can find this: TIFF readers must be prepared th handle all three values for ResolutionUnit.

Edited by user Wednesday, December 19, 2007 4:26:01 PM(UTC)  | Reason: Not specified

Andrew  
#4 Posted : Monday, June 12, 2006 10:44:45 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Thank you for your input, Stefan!
dantuck_777  
#5 Posted : Wednesday, May 30, 2007 8:13:15 PM(UTC)
dantuck_777

Rank: Member

Groups: Member
Joined: 5/30/2007(UTC)
Posts: 1

Hello,

Does anyone know how I would get the resolution in pixels of a TIFF file (eg 800x600). If anyone has a piece of code in VBA to do this it would be much appreciated.

Need to find this information so that the image can then be displayed with the correct orientation.

Daniel.

tuck.daniel AT gmail.com
Dmitry  
#6 Posted : Thursday, May 31, 2007 5:07:59 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello Daniel,

You should load image to Bitmap oboject from Tiff file and get values of Width and Height properties.

Edited by user Tuesday, December 15, 2009 10:44:34 AM(UTC)  | Reason: Not specified

Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.