Reputation: 1423
I have a huge number of DJVU files and I need to convert them all to TIFF files. They are all part of a local website. By local I mean unpublished website. It's built like a map, using JPEG imagery, PNG and GIF with transparency for layout of the overview map, HTML, CSS and some JavaScript (with jquery). Each part of the overview map is associated with a specific DJVU file. When you click on a part of the map a new browser window opens and shows you the actual geographical map stored in the DJVU file.
I will attempt to explain the structure here. Example of DJVU file:
112_87_10_0.djvu
This will have to be converted to TIFF and also renamed, like this:
HEK_S044_Vitsand_1883-95.tif
It will also have to be stored in a new folder with a similar name. In this example, the name of the folder would be like this:
044 Vitsand
So the search path for the converted file would be like this:
044 Vitsand\HEK_S044_Vitsand_1883-95.tif
The number 44 with preceding 0 is just a number. Vitsand is the name of the map sheet and also the name of a small village in Värmland County, Sweden. The letter S is the designation for the county, according to ISO 3166. The last part is a year interval for when the map was made.
My problem is that this takes time to do manually, and I can easily introduce errors by simply being bored by this after doing it for an extended time period. How can this be automated? I'm not really a programmer. In fact I have only recently started learning JavaScript. Does anyone feel like writing a script for me? At least, please give me some pointers as to what language, method and tools to use and so on.
I poked around in a file named lan_s.js
and I can see it contains all the bits of information I am using to manually name the files. Here's what the corresponding line for the DJVU file above looks like:
<area onmouseover=\"tooltip.show('Vitsand', 150);\" onmouseout=\"tooltip.hide();\" href=\"javascript: openMapEx('Värmlands län', 'J112-87-10','Vitsand','112_87_10_0.djvu','1883-95')\" alt=\"Vitsand\" shape=\"poly\" coords=\"144,154,166,155,166,172,143,171\">\
This is stored between <map name=\"slan_harads\">\
and </map>\
. I'm not sure what those backslashes represent, but they seem to be redundant. There are more <area>
tags in there, too many to post it here. But they all have the same syntax, but the map sheet name varies, the DJVU file name varies and the map year varies. So the Vitsand','112_87_10_0.djvu','1883-95
is the most important part here. The file lan_s.js
covers the entire Värmland county. There are other files just like it for other counties. I would need to do the same thing with those.
I would like to use a tool like Image Magick for the conversion process. It can convert DJVU to TIFF, and it allows me to explicitly set the compression to none. I don't want to use a tool that applies LZW compression without asking me.
(For the curious, the HEK is a short for "Härads-Ekonomisk-Karta". A "härad" was a type of geographic division formerly used in Sweden. It's comparable to a "Hundred" used in England and other English speaking countries.)
start.html
<html>
<head>
<title>Welcome!</title>
<style type="text/CSS">
</style>
<script type="text/javascript">
window.onload=timeout;
function timeout(){
window.setTimeout("redirect()",3000)}
function redirect(){
window.location="DATA/index.html"
return}
</script>
</head>
<body>
<img src="DATA/images/new_splash.jpg">
<body onload="timeout()" onClick="redirect()">
</body>
</html>
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Häradsekonomiska kartan</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="hek.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.maphilight.min.js"></script>
<script type="text/javascript">$(function() { $('.map').maphilight(); });</script>
<script language="javascript" src="lan.js"></script>
<script type="text/javascript" src="lan_bd.js"></script>
<script type="text/javascript" src="lan_ab.js"></script>
<script type="text/javascript" src="lan_c.js"></script>
<script type="text/javascript" src="lan_d.js"></script>
<script type="text/javascript" src="lan_e.js"></script>
<script type="text/javascript" src="lan_k.js"></script>
<script type="text/javascript" src="lan_m.js"></script>
<script type="text/javascript" src="lan_n.js"></script>
<script type="text/javascript" src="lan_o.js"></script>
<script type="text/javascript" src="lan_s.js"></script>
<script type="text/javascript" src="lan_t.js"></script>
<script type="text/javascript" src="lan_u.js"></script>
<script type="text/javascript" src="lan_w.js"></script>
<script type="text/javascript" src="hlp.js"></script>
<style type="text/css" media="screen">
/* local styles here */
</style>
</head>
I have intentionally left out the body tag here. It's just too much, the lines expand horizontally for all eternity.
lan_s.js
So here is the JavaScript file I referred to above.
var lan_s = "\
<map name=\"slan_harads\">\
LINES LINES LINES...
<area onmouseover=\"tooltip.show('Vägsjöfors', 150);\" onmouseout=\"tooltip.hide();\" href=\"javascript: openMapEx('Värmlands län', 'J112-87-15','Vägsjöfors','112_87_15_0.djvu','1883-95')\" alt=\"Vägsjöfors\" shape=\"poly\" coords=\"143,171,166,172,165,189,142,188\">\
<area onmouseover=\"tooltip.show('Vitsand', 150);\" onmouseout=\"tooltip.hide();\" href=\"javascript: openMapEx('Värmlands län', 'J112-87-10','Vitsand','112_87_10_0.djvu','1883-95')\" alt=\"Vitsand\" shape=\"poly\" coords=\"144,154,166,155,166,172,143,171\">\
<area onmouseover=\"tooltip.show('Kärnberget', 150);\" onmouseout=\"tooltip.hide();\" href=\"javascript: openMapEx('Värmlands län', 'J112-87-5','Kärnberget','112_87_5_0.djvu','1883-95')\" alt=\"Kärnberget\" shape=\"poly\" coords=\"145,138,167,139,166,155,144,154\">\
MORE LINES...
</map>\
\
\
<img src=\"ROOT/LAN/images/s.gif\" usemap=\"#slan_harads\" border=0>\
\
";
Upvotes: 1
Views: 571
Reputation: 3186
You won't be able to do this with just Javascript, as javascript has no inherent access to the filesystem.
Options then:
The real problem at hand is determining how your renaming scheme can fit some neat rule from which to write an automated script.
Taking Example of DJVU file: 112_87_10_0.djvu
and convert/rename to: HEK_S044_Vitsand_1883-95.tif
There needs to be a pattern from which one can apply the following logic.
As of right now, you could easily write a script that converts all files such as this:
112_87_10_0.djvu ==> 112_87_10_0.tif
But until you can provide some additional ruleset for the renaming schema the rest of your question remains unanswerable.
EDIT
Upon further review I do see that you provide some information in regards to getting the naming schema.. I shall look at that a bit more and revise my answer. If you could though, please remove all irrelevant information from your question, specificially the start and index.html bits, there is really nothing in that code of any importance to the question, and merely serves to obfuscate the important bits.
Upvotes: 1