'use strict'; /* global CONFIG_MAX_IMAGE_PIXEL_SIZE, CONFIG_REQUIRED_EXIF_PREVIEW_HEIGHT, CONFIG_REQUIRED_EXIF_PREVIEW_WIDTH, cropResizeRotate, Downsample, getImageSize, getVideoRotation, isPhone, parseJPEGMetadata, videostorage */ /* exported metadataParser */ // // This file defines a single metadataParsers object. The two // properties of this object are metadata parsing functions for image // files and video files, intended for use with the MediaDB class. // // This file depends on JPEGMetadataParser.js and blobview.js // var metadataParser = (function() { // If we generate our own thumbnails, aim for this size. // Calculate needed size from longer side of the screen. var THUMBNAIL_WIDTH = computeThumbnailWidth(); var THUMBNAIL_HEIGHT = THUMBNAIL_WIDTH; function computeThumbnailWidth() { // Make sure this works regardless of current device orientation var width = window.innerWidth || screen.width; var height = window.innerHeight || screen.height; var portraitWidth = Math.max(1, Math.min(width, height)); var landscapeWidth = Math.max(1, Math.max(width, height)); var thumbnailsPerRowPortrait = isPhone ? 3 : 4; var thumbnailsPerRowLandscape = isPhone ? 4 : 6; return Math.round(window.devicePixelRatio * Math.max(portraitWidth / thumbnailsPerRowPortrait, landscapeWidth / thumbnailsPerRowLandscape)); } var thumbnailSize = { width: THUMBNAIL_WIDTH, height: THUMBNAIL_HEIGHT }; // Don't try to decode image files of unknown type if bigger than this var MAX_UNKNOWN_IMAGE_FILE_SIZE = 0.5 * 1024 * 1024; // half a megabyte // If a jpeg does not have a suitable EXIF preview and has more than // this number of pixels, then we create an external preview for it var MAX_PREVIEWLESS_JPEG_SIZE = 5 * 1024 * 1024; // 5 megapixels // An element for loading images var offscreenImage = new Image(); // The screen size. Preview images must be at least this big // Note that we use screen.width instead of window.innerWidth because // the window size is different when we are invoked for a pick activity // (non-fullscreen) and when we are invoked normally (fullscreen). var sw = screen.width * window.devicePixelRatio; var sh = screen.height * window.devicePixelRatio; // Create a thumbnail size canvas, copy the or