Welcome to Dream.In.Code
Become a Java Expert!

Join 149,513 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,354 people online right now. Registration is fast and FREE... Join Now!




TIFF IMAGES

 
Reply to this topicStart new topic

TIFF IMAGES, The first data structure found in every TIFF file is called the Image

ssaikh
13 Aug, 2007 - 02:01 PM
Post #1

New D.I.C Head
*

Joined: 13 Aug, 2007
Posts: 2


My Contributions
CODE

public void readImageHeaders(String county)
{
try {
    
    String sql = " select image_data,id_image,dt_created,ID_VOTER from images where ID_VOTER in ('102013897','105453644') and FL_CURRENT='Y'";
   ResultSet resultSet = connection.executeQuery(sql);
    int id_Image=0;
    
    File newFolder=new File("C:\\Images\\CorrectImages");
    newFolder.mkdir();
    
    while(resultSet.next())
    {
                
        id_Image = resultSet.getInt("ID_VOTER");
            InputStream stream = resultSet.getBinaryStream("IMAGE_DATA");
           File outputFile1 = new File("C:\\Images\\CorrectImages\\"+id_Image+".tiff");
        
           FileOutputStream fos1 = new FileOutputStream(outputFile1);
        
           int a1 = stream.read();
           
           int k=0;
            while (a1 >= 0) {
                if(k<8)
                {
                    System.out.print((char)a1+",");
                }
                if(k==8)
                    System.out.println("");
                k++;
               fos1.write((char)a1);
                a1 = stream.read();
            }
       
        
}
    connection.commit();
    

}
catch (Exception sqlexcep)
{
    logger.error(sqlexcep);
    sqlexcep.printStackTrace();
}
}


I am trying to read the whole information about the Image File Header:IFH.(8 Bytes).
which are byte-ordering field in the IFH ,version field in the IFH ,offset in bytes from the start of the file to the Image File Directory, or IFD, structure.

How should i modify the above program do read all this information form a given image, so that i can
furthrer analyze these TIFF images.


User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: TIFF IMAGES
21 Aug, 2007 - 03:58 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
you will want to use a byte array, thus you can analyze each byte by char to get the info located there, without skipping any data. There is a good example of this in the Steganography Tutorial or you can look it up separately.
I am unfamiliar with the header of a .tiff file, do you know what data you are expecting?
User is offlineProfile CardPM
+Quote Post

ssaikh
RE: TIFF IMAGES
22 Aug, 2007 - 05:29 AM
Post #3

New D.I.C Head
*

Joined: 13 Aug, 2007
Posts: 2


My Contributions
QUOTE(William_Wilson @ 21 Aug, 2007 - 04:58 PM) *

you will want to use a byte array, thus you can analyze each byte by char to get the info located there, without skipping any data. There is a good example of this in the Steganography Tutorial or you can look it up separately.
I am unfamiliar with the header of a .tiff file, do you know what data you are expecting?


Each image has a Image header which stores the image type, such as a GifImage will have GIF stored
in the first 32 bytes along with the other informations. Other information includes of the
1) Total Pages
2) Image Size
3) Compression

I am unable to read the above three inforamtion, where as i am able to read the type of image i.e
if it is a GIF or TIFF or JPEG etc.
Thank you for your response. Could you post your reply when ever you have some suggestion on this.

User is offlineProfile CardPM
+Quote Post

1lacca
RE: TIFF IMAGES
22 Aug, 2007 - 06:58 AM
Post #4

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
I haven't dealt with TIFF files a lot, but looking at the
specification it is a bit more complex, than what you describe.
Anyway, since TIFF files support different byteorders, and even the header information depends on it, are you sure, you recognize the byteorder correctly, and process the header according to it?
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: TIFF IMAGES
22 Aug, 2007 - 07:08 AM
Post #5

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
from what i know of tiff files, there is much more than this information located in the header. There is in fact a count of tags as well as a length of each tag located within the header, which is an indicator that the header is not of a static length, like bmp would be.

this same problem arises in the different file formats. Tiff places a version number in the first few bytes of the file, while other formats may not. Different versions of the same file will also hold the data differently.

have you looked up what these file headers involve? I've used png, bmp, mp3, wav, and jpg regularly, and they are all special cases which need to be handled, as the type name is not in the same place in each file, if it's even there at all.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:45PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month