summaryrefslogtreecommitdiffstats
path: root/tests/imgPhoto.test
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-05-27 19:59:05 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-05-27 19:59:05 (GMT)
commitdd57d00f5c65deebb5bea67608c586856c2c2b7a (patch)
treed02c9d8ce3825965958eace3ac9dc332a16cb6b6 /tests/imgPhoto.test
parent23939f2bcfdb6b294e21484ee5327b550ebdd824 (diff)
downloadtk-dd57d00f5c65deebb5bea67608c586856c2c2b7a.zip
tk-dd57d00f5c65deebb5bea67608c586856c2c2b7a.tar.gz
tk-dd57d00f5c65deebb5bea67608c586856c2c2b7a.tar.bz2
TIP529 image metadata: correct and test GIF XMP segment
Diffstat (limited to 'tests/imgPhoto.test')
-rw-r--r--tests/imgPhoto.test93
1 files changed, 91 insertions, 2 deletions
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index 13070e2..b7434a9 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -2133,8 +2133,7 @@ test imgPhoto-22.3 {option -metadata, clear value} -setup {
# 23.x GIF images with metadata
-# The following gif prefix data is used by the following data.
-# The trailer \x3b is missing
+# The following gif core data is used by the following data.
# N.B. this is the same image as test imgPhoto-18.10
# size 16x16, global color table size: 8
@@ -2176,6 +2175,96 @@ test imgPhoto-23.2 {GIF comment after image data} -setup {
catch {image delete gif1}
} -result {Comment ABCD}
+test imgPhoto-23.3 {Two GIF comment blocks} -setup {
+ set data $::gifstart
+ # Append a comment extension block with data "1234"
+ append data "\x21\xfe\x04" "1234" "\x0"
+ append data $::gifdata
+ # Append a comment extension block with data "ABCD"
+ append data "\x21\xfe\x04" "ABCD" "\x0"
+ # Trailer
+ append data $::gifend
+} -body {
+ image create photo gif1 -data $data
+ gif1 cget -metadata
+} -cleanup {
+ catch {image delete gif1}
+} -result {Comment ABCD}
+
+test imgPhoto-23.4 {XMP comment block before image} -setup {
+ set data $::gifstart
+ # Append an XMP comment extension block (including a Unicode codepoint 2022
+ set xmpdata "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\
+ xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\">\
+ <rdf:Description rdf:about=\"1\u2022\">\
+ <xmp:Rating>3</xmp:Rating></rdf:Description></rdf:RDF>"
+ append data "\x21\xff\x0B" "XMP DataXMP" [encoding convertto utf-8 $xmpdata]
+ # Special trailer of 1 ff fe ... 02 01 00 00
+ append data "\x01"
+ for {set i 0xff} {$i != -1} {incr i -1} {
+ append data [binary format c $i]
+ }
+ append data "\x00"
+
+ append data $::gifdata
+ # Trailer
+ append data $::gifend
+} -body {
+ image create photo gif1 -data $data
+ set d [dict get [gif1 cget -metadata] XMP]
+ expr {$d eq $xmpdata}
+} -cleanup {
+ catch {image delete gif1}
+} -result {1}
+
+test imgPhoto-23.5 {XMP comment block after image} -setup {
+ set data $::gifstart
+ append data $::gifdata
+
+ # Append an XMP comment extension block (including a Unicode codepoint 2022
+ set xmpdata "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\
+ xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\">\
+ <rdf:Description rdf:about=\"1\u2022\">\
+ <xmp:Rating>3</xmp:Rating></rdf:Description></rdf:RDF>"
+ append data "\x21\xff\x0B" "XMP DataXMP" [encoding convertto utf-8 $xmpdata]
+ # Special trailer of 1 ff fe ... 02 01 00 00
+ append data "\x01"
+ for {set i 0xff} {$i != -1} {incr i -1} {
+ append data [binary format c $i]
+ }
+ append data "\x00"
+
+ # Trailer
+ append data $::gifend
+} -body {
+ image create photo gif1 -data $data
+ set d [dict get [gif1 cget -metadata] XMP]
+ expr {$d eq $xmpdata}
+} -cleanup {
+ catch {image delete gif1}
+} -result {1}
+
+test imgPhoto-23.6 {empty XMP comment block after image} -setup {
+ set data $::gifstart
+ append data $::gifdata
+
+ append data "\x21\xff\x0B" "XMP DataXMP"
+ # Special trailer of 1 ff fe ... 02 01 00 00
+ append data "\x01"
+ for {set i 0xff} {$i != -1} {incr i -1} {
+ append data [binary format c $i]
+ }
+ append data "\x00"
+
+ # Trailer
+ append data $::gifend
+} -body {
+ image create photo gif1 -data $data
+ dict get [gif1 cget -metadata] XMP
+} -cleanup {
+ catch {image delete gif1}
+} -result {}
+
unset -nocomplain gifstart gifdata gifend