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

Posted on 1997-11-02
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
Question by:montek
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
LVL 84

Expert Comment

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

Author Comment

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

Expert Comment

ID: 1831051
Even if you access it from the .tif name?
What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.


Author Comment

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.

Expert Comment

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
$file= '/path/'.$ENV{'QUERY_STRING'};
if (!open(TIFF, "<$file")) {
    print "Content-type: text/plain\n\nCan't open TIFF file: $file\n";
binmode TIFF;
binmode STDOUT;
print "Content-type: image/tiff\n\n";
$blocksize = 2048;
while (!eof(TIFF)) {
    read TIFF,$tiffdata,$blocksize;
    print $tiffdata;


Author Comment

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.


Expert Comment

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".

Accepted Solution

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).

Author Comment

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!)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

627 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