File tree Expand file tree Collapse file tree 2 files changed +34
-29
lines changed Expand file tree Collapse file tree 2 files changed +34
-29
lines changed Original file line number Diff line number Diff line change
1
+ use std:: error:: Error ;
2
+ use std:: path:: Path ;
3
+
4
+ use iptc:: IPTC ;
5
+ use iptc:: IPTCTag ;
6
+
7
+ #[ test]
8
+ fn exiv2_iptc_example ( ) -> Result < ( ) , Box < dyn Error > > {
9
+ // https://exiv2.org/examples.html
10
+ // Example 3: iptcprint.cpp
11
+
12
+ let image_path = Path :: new ( "tests/smiley.jpg" ) ;
13
+ let iptc = IPTC :: read_from_path ( & image_path) ?;
14
+
15
+ let tags = iptc. get_all ( ) ;
16
+ println ! ( "IPTC: {:?}" , tags) ;
17
+
18
+ let keywords = iptc. get ( IPTCTag :: Keywords ) ;
19
+ assert_eq ! ( keywords, "Yet another keyword" ) ;
20
+
21
+ let date_created = iptc. get ( IPTCTag :: DateCreated ) ;
22
+ assert_eq ! ( date_created, "20040803" ) ;
23
+
24
+ let urgency = iptc. get ( IPTCTag :: Urgency ) ;
25
+ assert_eq ! ( urgency, "very!" ) ;
26
+
27
+ let model_version = iptc. get ( IPTCTag :: ModelVersion ) ;
28
+ assert_eq ! ( model_version, "42" ) ;
29
+
30
+ let time_sent = iptc. get ( IPTCTag :: TimeSent ) ;
31
+ assert_eq ! ( time_sent, "144100-0500" ) ;
32
+
33
+ Ok ( ( ) )
34
+ }
Original file line number Diff line number Diff line change @@ -5,35 +5,6 @@ use std::path::Path;
5
5
use iptc:: IPTC ;
6
6
use iptc:: IPTCTag ;
7
7
8
- #[ test]
9
- fn exiv2_iptc_example ( ) -> Result < ( ) , Box < dyn Error > > {
10
- // https://exiv2.org/examples.html
11
- // Example 3: iptcprint.cpp
12
-
13
- let image_path = Path :: new ( "tests/smiley.jpg" ) ;
14
- let iptc = IPTC :: read_from_path ( & image_path) ?;
15
-
16
- let tags = iptc. get_all ( ) ;
17
- println ! ( "IPTC: {:?}" , tags) ;
18
-
19
- let keywords = iptc. get ( IPTCTag :: Keywords ) ;
20
- assert_eq ! ( keywords, "Yet another keyword" ) ;
21
-
22
- let date_created = iptc. get ( IPTCTag :: DateCreated ) ;
23
- assert_eq ! ( date_created, "20040803" ) ;
24
-
25
- let urgency = iptc. get ( IPTCTag :: Urgency ) ;
26
- assert_eq ! ( urgency, "very!" ) ;
27
-
28
- let model_version = iptc. get ( IPTCTag :: ModelVersion ) ;
29
- assert_eq ! ( model_version, "42" ) ;
30
-
31
- let time_sent = iptc. get ( IPTCTag :: TimeSent ) ;
32
- assert_eq ! ( time_sent, "144100-0500" ) ;
33
-
34
- Ok ( ( ) )
35
- }
36
-
37
8
#[ test]
38
9
fn test_write_iptc ( ) -> Result < ( ) , Box < dyn Error > > {
39
10
// Create a copy of the test file so we don't modify the original
You can’t perform that action at this time.
0 commit comments