Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17930 from davidflanagan/bug990630
Browse files Browse the repository at this point in the history
Bug 990630: extract the EXIF preview metadata that media frame needs r=jdarcangelo
  • Loading branch information
David Flanagan committed Apr 3, 2014
2 parents 4a2e203 + 54c5d48 commit 0e974ff
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
15 changes: 10 additions & 5 deletions apps/camera/README.md
Expand Up @@ -119,14 +119,19 @@ Our `Makefile` has two tasks, one to **'build'** and one to **'clean'** (delete
3. Copy all the entire `shared/` directory into our build directory. This is so that any shared dependencies that we are using are available in `build_stage/camera/shared/`, mimicking the magically resolved `/shared/` HTTP requests in development.
4. Run the `r.js` (RequireJS optimizer), pointing it at our `require_config.jslike` file (`.jslike` because we don't want Gaia builds to mess with it [I think]). This copies our entire application (JS and all) and bundles our JS (tracing `require()` calls) and CSS (tracing `@import`) in two single files.

## Old code
## Debug messages in javascript console

The are still some modules have not been reworked into the new architecture:
- To enable debug messages for all modules

- [panzoom.js](js/panzoom.js)
- [filmstrip.js](js/filmstrip.js)
localStorage.debug = '*'

As far as I know there is nothing blocking work on aligning `confirm.js` and `panzoom.js` with our new architecture. `filmstrip.js` has been touched as little as possible as plans in `1.4` propose very different funtionality. Therefore work to refactor this module would probably be discarded as `1.4` features are implemented.
- To enable debug messages for a particular module

localStorage.debug = 'controllers:hud'

- To disable debug messages:

localStorage.removeItem('debug')

## Activities

Expand Down
36 changes: 24 additions & 12 deletions apps/camera/js/controllers/preview-gallery.js
Expand Up @@ -8,8 +8,8 @@ define(function(require, exports, module) {
var debug = require('debug')('controller:preview-gallery');
var bindAll = require('lib/bind-all');
var PreviewGalleryView = require('views/preview-gallery');
var parseJPEGMetadata = require('jpegMetaDataParser');
var createThumbnailImage = require('lib/create-thumbnail-image');
var preparePreview = require('lib/prepare-preview-blob');

/**
* The size of the thumbnail images we generate.
Expand Down Expand Up @@ -236,8 +236,24 @@ PreviewGalleryController.prototype.onNewMedia = function(item) {
return;
}

this.items.unshift(item);
this.updateThumbnail();
var self = this;

if (item.isVideo) {
// If the new media is video, use it as-is
addNewMedia(item);
} else {
// If it is a photo, find its EXIF preview first
preparePreview(item.blob, function(metadata) {
metadata.blob = item.blob;
metadata.filepath = item.filepath;
addNewMedia(metadata);
});
}

function addNewMedia(item) {
self.items.unshift(item);
self.updateThumbnail();
}
};

PreviewGalleryController.prototype.previewItem = function() {
Expand Down Expand Up @@ -309,24 +325,20 @@ PreviewGalleryController.prototype.updateThumbnail = function() {
media.rotation, media.mirrored, gotThumbnail);
} else {
// If it is a photo we want to use the EXIF preview rather than
// decoding the whole image if we can, so look for a preview first.
parseJPEGMetadata(media.blob, onJPEGParsed);
}

function onJPEGParsed(metadata) {
// decoding the whole image if we can.
var blob;

if (metadata.preview) {
if (media.preview) {
// If JPEG contains a preview we use it to create the thumbnail
blob = media.blob.slice(metadata.preview.start, metadata.preview.end,
blob = media.blob.slice(media.preview.start, media.preview.end,
'image/jpeg');
} else {
// Otherwise, use the full-size image
blob = media.blob;
}

createThumbnailImage(blob, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT,
metadata.rotation, metadata.mirrored, gotThumbnail);
media.rotation, media.mirrored, gotThumbnail);

}

function gotThumbnail(blob) {
Expand Down
4 changes: 2 additions & 2 deletions apps/camera/test/unit/controllers/preview-gallery_test.js
Expand Up @@ -165,7 +165,7 @@ suite('controllers/preview-gallery', function() {
var item = {
blob: {},
filepath: 'root/fileName',
isVideo: false
isVideo: true
};

this.app.activity = {
Expand All @@ -183,7 +183,7 @@ suite('controllers/preview-gallery', function() {
var item = {
blob: {},
filepath: 'root/fileName',
isVideo: false
isVideo: true
};

var data = {
Expand Down

0 comments on commit 0e974ff

Please sign in to comment.