Solved

Using TIFF plug-in with files that have a different extension

Posted on 1997-11-02
9
148 Views
Last Modified: 2013-12-25
I am trying to write a CGI application in C that queries a database (that part works) and returns a web page that refers to images (they are newspaper articles that have been scanned).

These images, however, have an .osm extension (that's the indexing extension required by the scanning/archiving software), but they are standard TIFF files.

I am using the TIFF plug-in by watermark and it seems to recognize .TIF files without a problem (of course), but cannot recognize this .OSMextension.

I have tried several things, including trying to mask the MIME type by returning "Content-type: image/tiff" and then using a binary spew of the contents of the file.  That returned garbage.  Then, I tried the Location parameter in front of that.  Similar problem.  I thought this could be as easy as convincing the web server that these
files were to be treated as TIFF files, but that hasn't worked (I even entered the new extension in the mime.typ file).  Right now, I am using the personal web server that comes with Front Page 98, but this will ported to IIS 3.0.
ANY help you can give me would be greatly appreciated
0
Comment
Question by:montek
  • 4
  • 3
  • 2
9 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1831049
Can you make a link from file.osm to file.tif?
0
 

Author Comment

by:montek
ID: 1831050
Just making a link does not invoke the Watermark TIFF plug-in.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1831051
Even if you access it from the .tif name?
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:montek
ID: 1831052
If I change the CGI code and the filename to .tif, it works fine.  There are gigabytes of .osm files, though, and changing the names can not work in this case.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1831053
I would think changing the mime type in the server config would work, since the server should tell the browser the file is type image/tiff. When you do so, what headers does the server send? Try telnetting to localhost port 80 (or whereever your server is) and get a tiff file, e.g. type GET /whatever/whatever/filename.osm HTTP/1.0 (followed by Enter twice) and the server will fetch that file for you. Turn on telnet logging so you can go and see what the headers were. If the server's not saying it's image/tiff it may be the server's fault, if it is it's probably the plugin's fault.

Perhaps the plugin doesn't care about mime type, which would be very strange. I can't get that particular plugin, the link from the Netscape plugins page is broken, maybe you have an address for it?

If all else fails, I agree a data-dump script is the way to go, since you can call it with the filename and it will get filename.osm off your system and return it with the tiff header. I wrote such a script in perl and it worked beautifully: the browser recognized the script output as a tiff file, and either activated an external viewer or wrote it to disk (where I verified it was byte-for-byte identical to the original file). I think you should duplicate this test as a next step - if you can get access to perl it would be a little easier to test. Here's my very simple test script:

# Call as tiff.pl?filename
$file= '/path/'.$ENV{'QUERY_STRING'};
if (!open(TIFF, "<$file")) {
    print "Content-type: text/plain\n\nCan't open TIFF file: $file\n";
    die;
}
binmode TIFF;
binmode STDOUT;
print "Content-type: image/tiff\n\n";
$blocksize = 2048;
while (!eof(TIFF)) {
    read TIFF,$tiffdata,$blocksize;
    print $tiffdata;
}
close(TIFF);

0
 

Author Comment

by:montek
ID: 1831054
Thanks, alamo.  I really appreciate the time you took to help me with this (you've even given me some new things to think about).  If you "answer" this question, I'll give you the points, because you deserve them.

Today, when I went to try it, everything worked.  You gotta love computers, huh?  Apparently, the MIME thing didn't kick in until today (I have no idea why).  Thanks again, everyone.

0
 
LVL 6

Expert Comment

by:alamo
ID: 1831055
Thanks, montek, glad it worked out, that is by far the easiest solution. For future reference, the server only reads its configuration when it starts up, if you didn't know that maybe that's why the mime types didn't "take".
0
 
LVL 6

Accepted Solution

by:
alamo earned 100 total points
ID: 1831056
I would think changing the mime type in the server config would work, why don't you try testing it again?  :-)

(Read the comments for some things to help in debugging this, no point reposting them here).
0
 

Author Comment

by:montek
ID: 1831057
It's funny, I did reboot the server, originally.  I don't know.  Sometimes things just work.  Anyway, thanks again!

(Ahh...computers...Gotta love 'em!)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question