1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
6 #define CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
18 class DrainableIOBuffer;
23 // Extracts a basic set of image metadata tags. Users must initialize the
24 // library before use. Each class instance is 'one-time-use', and cannot be used
25 // to extract metadata from multiple images.
26 class ImageMetadataExtractor {
28 typedef base::Callback<void(bool)> DoneCallback;
30 // One of these two is required before use of this class.
31 static bool InitializeLibrary();
32 static bool InitializeLibraryForTesting();
34 ImageMetadataExtractor();
35 ~ImageMetadataExtractor();
37 // |callback| called with whether or not the extraction succeeded. Should
38 // only be called once.
39 void Extract(media::DataSource* source, const DoneCallback& callback);
41 // All below methods require Extract to have already succeeded.
42 // Returns -1 if file does not define a width or height.
49 // In pixels per inch.
50 double x_resolution() const;
51 double y_resolution() const;
53 // In the same string form as the original file.
54 const std::string& date() const;
56 const std::string& camera_make() const;
57 const std::string& camera_model() const;
58 double exposure_time_sec() const;
59 bool flash_fired() const;
60 double f_number() const;
61 double focal_length_mm() const;
62 int iso_equivalent() const;
65 // Second half of the Extract method.
66 void FinishExtraction(const DoneCallback& callback,
67 net::DrainableIOBuffer* buffer);
81 std::string camera_make_;
82 std::string camera_model_;
83 double exposure_time_sec_;
86 double focal_length_mm_;
89 DISALLOW_COPY_AND_ASSIGN(ImageMetadataExtractor);
92 } // namespace metadata
94 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IMAGE_METADATA_EXTRACTOR_H_