Add test/data/artificial/gif-transparent-index.gif
diff --git a/script/make-artificial.go b/script/make-artificial.go
index 61468e8..9de99ab 100644
--- a/script/make-artificial.go
+++ b/script/make-artificial.go
@@ -958,40 +958,51 @@
 		s := line[len(cmdGC):]
 
 		flags := uint8(0)
-		if i := strings.IndexByte(s, ' '); i < 0 {
-			break
-		} else {
-			switch s[:i] {
-			case "animationDisposalNone":
+		duration := uint32(0)
+		transparentIndex := uint32(0)
+		for s != "" {
+			term := ""
+			if i := strings.IndexByte(s, ' '); i >= 0 {
+				term, s = s[:i], s[i+1:]
+			} else {
+				term, s = s, ""
+			}
+
+			const (
+				ms    = "ms"
+				trans = "transparentIndex="
+			)
+			switch {
+			case term == "animationDisposalNone":
 				flags |= 0x00
-			case "animationDisposalRestoreBackground":
+			case term == "animationDisposalRestoreBackground":
 				flags |= 0x08
-			case "animationDisposalRestorePrevious":
+			case term == "animationDisposalRestorePrevious":
 				flags |= 0x0C
+			case strings.HasPrefix(term, trans):
+				num, remaining, ok := parseNum(term[len(trans):])
+				if !ok || remaining != "" {
+					break outer
+				}
+				flags |= 0x01
+				transparentIndex = num
+			case strings.HasSuffix(term, ms):
+				num, remaining, ok := parseNum(term[:len(term)-len(ms)])
+				if !ok || remaining != "" {
+					break outer
+				}
+				duration = num / 10 // GIF's unit of time is 10ms.
 			default:
 				break outer
 			}
-			s = s[i+1:]
 		}
 
-		if !strings.HasSuffix(s, "ms") {
-			break
-		}
-		s = s[:len(s)-2]
-		duration, s, ok := parseNum(s)
-		if !ok || s != "" {
-			break
-		}
-		duration /= 10 // GIF's unit of time is 10ms.
-
-		transparentIndex := uint8(0)
-
 		out = append(out,
 			0x21, 0xF9, 0x04,
 			flags,
 			uint8(duration>>0),
 			uint8(duration>>8),
-			transparentIndex,
+			uint8(transparentIndex),
 			0x00,
 		)
 		return stateGif, nil
diff --git a/test/data/artificial/gif-transparent-index.gif b/test/data/artificial/gif-transparent-index.gif
new file mode 100644
index 0000000..a9f0e09
--- /dev/null
+++ b/test/data/artificial/gif-transparent-index.gif
Binary files differ
diff --git a/test/data/artificial/gif-transparent-index.gif.make-artificial.txt b/test/data/artificial/gif-transparent-index.gif.make-artificial.txt
new file mode 100644
index 0000000..96f05c0
--- /dev/null
+++ b/test/data/artificial/gif-transparent-index.gif.make-artificial.txt
@@ -0,0 +1,36 @@
+# Feed this file to script/make-artificial.go
+
+make gif
+
+header
+
+image {
+	imageWidthHeight 4 1
+	# Four shades of red and then green, cyan, blue, white.
+	palette {
+		0x80 0x00 0x00
+		0x90 0x00 0x00
+		0xA0 0x00 0x00
+		0xB0 0x00 0x00
+		0x00 0xC0 0x00
+		0x00 0xD0 0xD0
+		0x00 0x00 0xE0
+		0xF0 0xF0 0xF0
+	}
+}
+
+graphicControl animationDisposalNone 100ms
+
+frame {
+	frameLeftTopWidthHeight 0 0 4 1
+}
+lzw 7 0x00 0x01 0x02 0x03
+
+graphicControl animationDisposalNone 200ms transparentIndex=5
+
+frame {
+	frameLeftTopWidthHeight 0 0 3 1
+}
+lzw 7 0x04 0x05 0x06
+
+trailer