Solved

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

Posted on 1997-11-02
9
147 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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

808 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