Commit e57ef9d2 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[piexwasm] Remove files app ColorSpace dependency

JEITA EXIF color space defines and supports two color spaces only per
the JEITA specification: sRGB and AdobeRGB1998.

The PIEX C++ returns their values as strings 'sRgb' and 'adobeRgb' so
return those values in the PiexLoaderResponse [1].

Note JEITA EXIF color space indicates the color space only. The image
does not have an embedded ICC Color Profile. A future option for piex
is to slice open the JPEG preview, insert an ICC Color Profile in the
AdobeRGB1998 case, before returning the PiexLoaderResponse.

[1] In files app, make image_request_task.js convert the value in the
PiexLoaderResponse to ColorSpace type. No change in behavior.

Bug: 1132695
Change-Id: Ifa076635dc5672a552094bf1b5fa9e69e164d9d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432150Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811128}
parent 9bfc98fe
...@@ -336,7 +336,9 @@ ImageRequestTask.prototype.downloadOriginal_ = function(onSuccess, onFailure) { ...@@ -336,7 +336,9 @@ ImageRequestTask.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
function(data) { function(data) {
this.request_.orientation = this.request_.orientation =
ImageOrientation.fromExifOrientation(data.orientation); ImageOrientation.fromExifOrientation(data.orientation);
this.request_.colorSpace = data.colorSpace; const isAdobeRgb = data.colorSpace === 'adobeRgb';
this.request_.colorSpace =
isAdobeRgb ? ColorSpace.ADOBE_RGB : ColorSpace.SRGB;
this.ifd_ = data.ifd; this.ifd_ = data.ifd;
this.contentType_ = data.mimeType; this.contentType_ = data.mimeType;
const blob = new Blob([data.thumbnail], {type: data.mimeType}); const blob = new Blob([data.thumbnail], {type: data.mimeType});
......
...@@ -64,7 +64,7 @@ function piexModuleFailed() { ...@@ -64,7 +64,7 @@ function piexModuleFailed() {
* thumbnail: !ArrayBuffer, * thumbnail: !ArrayBuffer,
* mimeType: (string|undefined), * mimeType: (string|undefined),
* orientation: number, * orientation: number,
* colorSpace: ColorSpace, * colorSpace: string,
* ifd: ?string * ifd: ?string
* }} * }}
*/ */
...@@ -96,7 +96,8 @@ function PiexLoaderResponse(data) { ...@@ -96,7 +96,8 @@ function PiexLoaderResponse(data) {
this.orientation = data.orientation; this.orientation = data.orientation;
/** /**
* @public {ColorSpace} * JEITA EXIF image color space: 'sRgb' or 'adobeRgb'.
* @public {string}
* @const * @const
*/ */
this.colorSpace = data.colorSpace; this.colorSpace = data.colorSpace;
...@@ -179,7 +180,7 @@ function readSourceData(source) { ...@@ -179,7 +180,7 @@ function readSourceData(source) {
* *
* @typedef {{ * @typedef {{
* format:number, * format:number,
* colorSpace:ColorSpace, * colorSpace:string,
* orientation:number, * orientation:number,
* width:?number, * width:?number,
* height:?number, * height:?number,
...@@ -298,7 +299,7 @@ class ImageBuffer { ...@@ -298,7 +299,7 @@ class ImageBuffer {
if (!thumbnail) { if (!thumbnail) {
return { return {
thumbnail: new ArrayBuffer(0), thumbnail: new ArrayBuffer(0),
colorSpace: ColorSpace.SRGB, colorSpace: 'sRgb',
orientation: 1, orientation: 1,
ifd: null, ifd: null,
}; };
...@@ -338,7 +339,7 @@ class ImageBuffer { ...@@ -338,7 +339,7 @@ class ImageBuffer {
if (!thumbnail || thumbnail.format !== 1) { if (!thumbnail || thumbnail.format !== 1) {
return { return {
thumbnail: new ArrayBuffer(0), thumbnail: new ArrayBuffer(0),
colorSpace: ColorSpace.SRGB, colorSpace: 'sRgb',
orientation: 1, orientation: 1,
ifd: null, ifd: null,
}; };
......
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