File: SkExif.h

package info (click to toggle)
webkit2gtk 2.51.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 455,340 kB
  • sloc: cpp: 3,865,253; javascript: 197,710; ansic: 165,177; python: 49,241; asm: 21,868; ruby: 18,095; perl: 16,926; xml: 4,623; sh: 2,409; yacc: 2,356; java: 2,019; lex: 1,330; pascal: 372; makefile: 210
file content (69 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (27)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * Copyright 2023 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkExif_DEFINED
#define SkExif_DEFINED

#include "include/codec/SkEncodedOrigin.h"
#include "include/core/SkRefCnt.h"
#include "include/private/base/SkAPI.h"

#include <cstdint>
#include <optional>

class SkData;

namespace SkExif {

// Tag values that are parsed by Parse and stored in Metadata.
static constexpr uint16_t kOriginTag = 0x112;
static constexpr uint16_t kResolutionUnitTag = 0x0128;
static constexpr uint16_t kXResolutionTag = 0x011a;
static constexpr uint16_t kYResolutionTag = 0x011b;
static constexpr uint16_t kPixelXDimensionTag = 0xa002;
static constexpr uint16_t kPixelYDimensionTag = 0xa003;

struct Metadata {
    // The image orientation.
    std::optional<SkEncodedOrigin> fOrigin;

    // The HDR headroom property.
    // https://developer.apple.com/documentation/appkit/images_and_pdf/applying_apple_hdr_effect_to_your_photos
    std::optional<float> fHdrHeadroom;

    // Resolution.
    std::optional<uint16_t> fResolutionUnit;
    std::optional<float> fXResolution;
    std::optional<float> fYResolution;

    // Size in pixels.
    std::optional<uint32_t> fPixelXDimension;
    std::optional<uint32_t> fPixelYDimension;
};

/*
 * Parse the metadata specified in |data| and write them to |metadata|. Stop only at an
 * unrecoverable error (allow truncated input).
 */
void SK_API Parse(Metadata& metadata, const SkData* data);

/*
 * Write exif data that includes the values in |metadata| and returns it as SkData
 * untruncated. Return nullptr if a write to the data stream fails or if
 * |metadata.fHdrHeadroom| has value.
 * This function cannot write an IFD entry based on the HdrHeadroom value because
 * the information of maker33 and maker48 are lost in decoding.
 * For metadata that belongs in a subIFD the function will write it to one and
 * store it after the root IFD.
 * Data that does not fit within kSizeEntry, is appended to the end of the data,
 * after the subIFD if it exists.
 */
sk_sp<SkData> WriteExif(Metadata& metadata);

}  // namespace SkExif

#endif