Solved

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

Posted on 1997-11-02
9
144 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
Comment Utility
Can you make a link from file.osm to file.tif?
0
 

Author Comment

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

Expert Comment

by:ozo
Comment Utility
Even if you access it from the .tif name?
0
 

Author Comment

by:montek
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 6

Expert Comment

by:alamo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now