[Photo Editor] Make exif encoder more tolerant to non-standard EXIF data

BUG=138967
TEST=

Review URL: https://chromiumcodereview.appspot.com/10833007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148369 0039d316-1c4b-4281-b951-d872f2087c98
parent deed0fd3
...@@ -321,8 +321,11 @@ ExifEncoder.encodeDirectory = function( ...@@ -321,8 +321,11 @@ ExifEncoder.encodeDirectory = function(
} }
}; };
// TODO(kaznacheev): Share with ExifParser? /**
// TODO(JSDOC) * @param {{format:number, id:number}} tag EXIF tag object.
* @return {number} Width in bytes of the data unit associated with this tag.
* TODO(kaznacheev): Share with ExifParser?
*/
ExifEncoder.getComponentWidth = function(tag) { ExifEncoder.getComponentWidth = function(tag) {
switch (tag.format) { switch (tag.format) {
case 1: // Byte case 1: // Byte
...@@ -342,7 +345,7 @@ ExifEncoder.getComponentWidth = function(tag) { ...@@ -342,7 +345,7 @@ ExifEncoder.getComponentWidth = function(tag) {
return 8; return 8;
default: // ??? default: // ???
throw new Error('Unknown tag format 0x' + console.warn('Unknown tag format 0x' +
Number(tag.id).toString(16) + ': ' + tag.format); Number(tag.id).toString(16) + ': ' + tag.format);
return 4; return 4;
} }
...@@ -383,7 +386,15 @@ ExifEncoder.writeValue = function(bw, tag) { ...@@ -383,7 +386,15 @@ ExifEncoder.writeValue = function(bw, tag) {
} }
}; };
//TODO(JSDOC) /**
* @param {{Object.<number,Object>}} directory EXIF directory.
* @param {number} id Tag id.
* @param {number} format Tag format
* (used in {@link ExifEncoder#getComponentWidth}).
* @param {number} componentCount Number of components in this tag.
* @return {{id:number, format:number, componentCount:number}}
* Tag found or created.
*/
ExifEncoder.findOrCreateTag = function(directory, id, format, componentCount) { ExifEncoder.findOrCreateTag = function(directory, id, format, componentCount) {
if (!(id in directory)) { if (!(id in directory)) {
directory[id] = { directory[id] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment