ret += data.charCodeAt(i);
}
return ret;
- }
+ };
/*
parse an signed number of size bytes at offset in some binary string data.
ret *= -1;
}
return ret;
- }
+ };
/* Rational number class */
JpegMeta.Rational = function Rational(num, den)
this.num = num;
this.den = den || 1;
return this;
- }
+ };
/* Rational number methods */
JpegMeta.Rational.prototype.toString = function toString() {
return this.num + " / " + this.den;
}
return this.num / this.den; // + "/" + this.den;
- }
+ };
JpegMeta.Rational.prototype.asFloat = function asFloat() {
return this.num / this.den;
- }
-
+ };
/* MetaGroup class */
JpegMeta.MetaGroup = function MetaGroup(fieldName, description) {
this.description = description;
this.metaProps = {};
return this;
- }
+ };
JpegMeta.MetaGroup.prototype._addProperty = function _addProperty(fieldName, description, value) {
var property = new JpegMeta.MetaProp(fieldName, description, value);
this[property.fieldName] = property;
this.metaProps[property.fieldName] = property;
- }
+ };
JpegMeta.MetaGroup.prototype.toString = function toString() {
return "[MetaGroup " + this.description + "]";
- }
-
-
+ };
+
/* MetaProp class */
JpegMeta.MetaProp = function MetaProp(fieldName, description, value) {
this.fieldName = fieldName;
this.description = description;
this.value = value;
return this;
- }
+ };
JpegMeta.MetaProp.prototype.toString = function toString() {
return "" + this.value;
- }
-
-
-
+ };
+
/* JpegFile class */
JpegMeta.JpegFile = function JpegFile(binary_data, filename) {
/* Change this to EOI if we want to parse. */
}
return this;
- }
+ };
this.JpegMeta.JpegFile.prototype.toString = function () {
return "[JpegFile " + this.filename + " " +
this.general.pixelWidth + "x" +
this.general.pixelHeight +
" Depth: " + this.general.depth + "]";
- }
+ };
/* Some useful constants */
this.JpegMeta.JpegFile.prototype._SOI_MARKER = '\xff\xd8';
this.general._addProperty("pixelHeight", "Pixel Height", JpegMeta.parseNum(">", this._binary_data, pos + 1, 2));
this.general._addProperty("pixelWidth", "Pixel Width",JpegMeta.parseNum(">", this._binary_data, pos + 3, 2));
this.general._addProperty("type", "Type", this._markers[mark][2]);
- }
+ };
/* JFIF idents */
this.JpegMeta.JpegFile.prototype._JFIF_IDENT = "JFIF\x00";
42016 : ["Unique image ID", "ImageUniqueID"],
40965 : ["Interoperability tag", "InteroperabilityIFDPointer"],
- }
+ };
this.JpegMeta.JpegFile.prototype._gpstags = {
/* A. Tags Relating to GPS */
28 : ["Name of GPS area", "GPSAreaInformation"],
29 : ["GPS Date", "GPSDateStamp"],
30 : ["GPS differential correction", "GPSDifferential"],
- }
-
-
+ };
+
this.JpegMeta.JpegFile.prototype._markers = {
/* Start Of Frame markers, non-differential, Huffman coding */
0xc0: ["SOF0", "_sofHandler", "Baseline DCT"],
/* Reserved markers */
0x01: ["JPG13", null], /* For temporary private use in arithmetic coding */
/* 02 -> bf are reserverd */
- }
-
+ };
+
/* Private methods */
this.JpegMeta.JpegFile.prototype._addMetaGroup = function _addMetaGroup(name, description) {
var group = new JpegMeta.MetaGroup(name, description);
this[group.fieldName] = group;
this.metaGroups[group.fieldName] = group;
return group;
- }
-
+ };
+
this.JpegMeta.JpegFile.prototype._parseIfd = function _parseIfd(endian, _binary_data, base, ifd_offset, tags, name, description) {
var num_fields = JpegMeta.parseNum(endian, _binary_data, base + ifd_offset, 2);
/* Per tag variables */
value = _binary_data.slice(value_offset, value_offset + num_values);
} else if (type == "ASCII") {
value = _binary_data.slice(value_offset, value_offset + num_values);
- value = value.split('\x00')[0]
+ value = value.split('\x00')[0];
/* strip trail nul */
} else {
value = new Array();
group._addProperty(tags[tag_field][1], tags[tag_field][0], value);
}
}
- }
-
+ };
+
this.JpegMeta.JpegFile.prototype._jfifHandler = function _jfifHandler(mark, pos) {
if (this.jfif !== undefined) {
throw Error("Multiple JFIF segments found");
this.jfif._addProperty("Ydensity", "Y Density", JpegMeta.parseNum(">", this._binary_data, pos + 10, 2));
this.jfif._addProperty("Xthumbnail", "X Thumbnail", JpegMeta.parseNum(">", this._binary_data, pos + 12, 1));
this.jfif._addProperty("Ythumbnail", "Y Thumbnail", JpegMeta.parseNum(">", this._binary_data, pos + 13, 1));
- }
-
-
+ };
+
/* Handle app0 segments */
this.JpegMeta.JpegFile.prototype._app0Handler = function app0Handler(mark, pos) {
var ident = this._binary_data.slice(pos, pos + 5);
} else {
/* Don't know about other idents */
}
- }
-
-
+ };
+
/* Handle app1 segments */
this.JpegMeta.JpegFile.prototype._app1Handler = function _app1Handler(mark, pos) {
var ident = this._binary_data.slice(pos, pos + 5);
} else {
/* Don't know about other idents */
}
- }
-
+ };
+
/* Handle exif segments */
JpegMeta.JpegFile.prototype._exifHandler = function _exifHandler(mark, pos) {
if (this.exif !== undefined) {