[File] [PATCH] of Magdir/riff for older Corel Draw Picture; *.cdr *.cdt *.cdrt *.pat

Jörg Jenderek joerg.jen.der.ek at gmx.net
Thu Jun 4 22:22:10 UTC 2020


Hello,
some weeks ago i send patches for newer Corel Drawings, which are zip
based. Later i run file command version 5.38 on older RIFF based
Corel Drawings with name extension cdr, cdt or cdrt for template and
pattern with pat extension. With -m Magdir/riff options i get an
output like:

03-FLORAL_3.CDR:                   RIFF (little-endian) data
06-be-test.cdr:                    RIFF (big-endian) data,
				   Corel Draw Picture, version 6
06-MS.CDR:                         RIFF (little-endian) data,
				   Corel Draw Picture, version 6
07-pattern10kb.cdr:                RIFF (little-endian) data
09-birds10k.cdr:                   RIFF (little-endian) data
10-be-test.cdr:                    RIFF (big-endian) data,
				   Corel Draw Picture
10-pattern10kb.cdr:                RIFF (little-endian) data,
				   Corel Draw Picture
11-cdr.cdr:                        RIFF (little-endian) data
BANK_BC.CDT:                       RIFF (little-endian) data
bird-v10.pat:                      RIFF (little-endian) data,
				   Corel Draw Picture
coreldraw13-v10.cdt:               RIFF (little-endian) data,
				   Corel Draw Picture
coreldraw13-v11.cdt:               RIFF (little-endian) data

All samples are at least general described by Magdir/riff  with line
 0	string		RIFF		RIFF (little-endian) data
but only samples with versions 10.0 and 6.0 are described as Corel
drawings by additional lines
 >8	string		CDRA	\b, Corel Draw Picture
 >8	string		CDR6	\b, Corel Draw Picture, version 6
Furthermore with --extension option only ??? is displayed.

Most information can be found on Corel Draw page on Wikipedia. So i
add a comment line:
 # URL:	http://en.wikipedia.org/wiki/CorelDRAW
Some information about such Corel Draw documents is found on
file formats archive team website. That is now expressed by comment
line like:
 # Reference:	http://fileformats.archiveteam.org/wiki/CorelDRAW

According to documentation the last character of second riff chunk is
a version indicator. Most samples start with upcased phrase CDR, but
intermediate version like 8 Bidi start with low cased phrase to
distinguish from version 8. So second test lines are replaced by
magic line like
 >8	string/c	cdr
But now the test are too generic. To skip Corel CCX Clip art i add an
additional test line and then call subroutine to display information
of RIFF based Corel Draw pictures, templates and patterns
 >>8	string		!CDRXcont
 >>>0	use     corel-draw
 0	name   	corel-draw
 >0	string		x		\b, Corel Draw
The advantage is that displaying can be easier maintained, because
the data chunk and meaning remain proprietary.

Later in subroutine i show version information by lines
 >11	string		x		\b, version
 >11	string		>\040		'%-.1s'
Til version 15 this can be interpreted as hexadecimal version number,
but this is not always true. For version 3 the space character is
used as version indicator and for intermediate version the RIFF type
is also different. For newer version in most cases the next
character in alphabet is used.
But luckily the version is also stored in another form. Til version
15 second chunk is followed by phrase vrsn. The size of this chunk is
two and the short content value can be interpreted as Major Version *
100 + Minor Version. So show numeric version information by lines
 >16	ulelong		2
 >>20	uleshort/100	x		%u
 >>20	uleshort%100	>0		\b.%u
So it is visible that intermediate version "8 Bidi" like in sample
08bi-yellowRectancleBlackLine.cdr has version indicator '8' but the
exact numeric version is 8.10, whereas version 8 like in example
08-longComment0k.cdr has numeric version 8.00 and also ASCII '8'
indicator. For files with version 16 and higher second chunk is
followed by phrase fver. The size of this chunk is sixteen and and
two bytes seems to be interpreted as Major Version and Minor Version.
This is now shown by lines like
 >16	ulelong		0x10
 >>34	ubyte		x		%u
 >>>33	ubyte		>0		\b.%u
So we see that version 22 Corel Draw Picture like example
22-cdr-root.dat has ASCII version indicator 'N' and correct numeric
version 22, but version 22 Corel Draw Picture template like
22-cdrt-root.dat has higher ASCII version indicator 'R' and numeric
version 22 because for templates exist some more intermediate versions.

For files with version 14 and higher the RIFF based is packed in a
ZIP archive.
For version 14 and 15 the filename seems to be always be riffdata.cdr.
For files with version 16 and higher the file name seems to be always
be root.dat.
So the filename extension depends on file format version. The file
name extension also depends on the sub types. There are 3 sub types
Picture, template and Patterns.

So as second part show sub type. First i handle some exceptions like
intermediate versions. So templates with version 4.4 are described by
lines like
 >>8	string		CDST		Picture template
 !:ext	cdt

To distinguish the sub type newer software like Corel Draw 2020 use
special second RIFF identifiers. So such pictures templates start
with RIFF type CDT and often now use cdrt extension instead cdt.
Such templates are described by lines like:
 >>8	string		CDT
 >>>12	string		=fver	Picture template (root.dat)
 !:ext	dat
 >>>12	string		!fver
 >>>>11	string		>E	Picture template (riffData.cdr)
 !:ext	cdr
 >>>>11	string		<F	Picture template
 !:ext	cdt/cdrt

The remaining older templates, patterns, drawings are caught by last
branch starting with line
 >>8	default		x
For all my patterns i found the fourth chunk size was 206C or D2C. I
hope that this observation is always true. So classify sub class
pattern by lines like
 >>>26	ulelong		=0x0000206C	Pattern
 !:ext	pat
 >>>26	ulelong		=0x00000D2C	Pattern
 !:ext	pat

In current magic mime type image/x-coreldraw was used, but most
sites use another one. That is now expressed by line
 !:mime	application/vnd.corel-draw

There exist also magic lines for big endian variants. This looks like
 0	string		RIFX	RIFF (big-endian) data
 >8	string		CDRA	\b, Corel Draw Picture
 >8	string		CDR6	\b, Corel Draw Picture, version 6

I changed these lines by lines like
 0	string		RIFX	RIFF (big-endian) data
 >8	string		CDR
 >>0	use     \^corel-draw
Unfortunately i have no real examples for big endian. So i do not
know if there exist also intermediate or higher versions. The above
construct works for my artificial samples *be-test.cdr .

Furthermore i was not able to distinguish version 12.5 Picture
template like 12.5-bw-x13-cdt.cdt from Corel Designer version 12,
because both use the same RIFF tag DESC. See
	http://fileformats.archiveteam.org/wiki/Corel_Designer
There exist also some other RIFF based file format used by Corel. I
will try to handle these in a future session.

After applying the above mentioned modifications by patch
file-5.38-riff-coreldraw.diff then nearly all different versions are
identified and i get a more precise output like:

03-FLORAL_3.CDR:                   RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 3, 42178 bytes
06-be-test.cdr:                    RIFF (big-endian) data,
				   Corel Draw Picture,
				   version '6' 6, 15558 bytes
06-MS.CDR:                         RIFF (little-endian) data,
				   Corel Draw Picture,
				   version '6' 6, 15558 bytes
07-pattern10kb.cdr:                RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '7' 7, 68928 bytes
08-longComment0k.cdr:              RIFF (little-endian) data,
				   Corel Draw Picture,
				   version '8' 8, 2072 bytes
08bi-yellowRectancleBlackLine.cdr: RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '8' 8.1, 12682 bytes
09-birds10k.cdr:                   RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '9' 9, 69622 bytes
10-be-test.cdr:                    RIFF (big-endian) data,
				   Corel Draw Picture,
				   version 'A' 10, 69172 bytes
10-pattern10kb.cdr:                RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version 'A' 10, 69172 bytes
11-cdr.cdr:                        RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'B' 11, 51692 bytes
11-cdrt.cdrt:                      RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'B' 11, 51684 bytes
11-Smiles0k.cdr:                   RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'B' 11, 2796 bytes
12-cdr.cdr:                        RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'C' 12, 51796 bytes
12.0-cdrt.cdrt:                    RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'C' 12, 51774 bytes
12.5-bw-x13-cdt.cdt:               RIFF (little-endian) data
12.5-cdrt.cdrt:                    RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'D' 12.50, 51774 bytes
13-cdr.cdr:                        RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'D' 13, 51834 bytes
13-cdrt.cdrt:                      RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'E' 13, 51814 bytes
14-cdr-riffData.cdr:               RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'E' 14, 1536 bytes
14-spray_trees2-riffData.cdr:      RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'E' 14, 98784 bytes
14.0-cdrt-riffData.cdr:            RIFF (little-endian) data,
				   Corel Draw Picture template
				   (riffData.cdr),
				   version 'F' 14, 4700 bytes
14.1-cdrt-riffData.cdr:            RIFF (little-endian) data,
				   Corel Draw Picture template
				   (riffData.cdr),
				   version 'G' 14.10, 4700 bytes
15-cdr-riffData.cdr:               RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'F' 15, 1536 bytes
15-drawX8-riffData.cdr:            RIFF (little-endian) data,
				   Corel Draw Picture,
				   version 'F' 15, 3196 bytes
15.0-cdrt-riffData.cdr:            RIFF (little-endian) data,
				   Corel Draw Picture template
				   (riffData.cdr),
				   version 'H' 15, 1536 bytes
15.1-cdrt-riffData.cdr:            RIFF (little-endian) data,
				   Corel Draw Picture template
				   (riffData.cdr),
				   version 'I' 15.10, 1536 bytes
16-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'G' 16, 1200 bytes
16.0-cdrt-root.dat:                RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'J' 16, 5268 bytes
16.3-cdrt-root.dat:                RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'K' 16.3, 5268 bytes
17-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'H' 17, 1200 bytes
17-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'L' 17, 1200 bytes
18-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'J' 18, 1200 bytes
18-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'N' 18, 1200 bytes
19-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'K' 19, 1200 bytes
19-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'O' 19, 1200 bytes
20-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'L' 20, 1200 bytes
20-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'P' 20, 1200 bytes
21-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'M' 21, 1200 bytes
21-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'Q' 21, 1200 bytes
22-cdr-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Picture
				   (root.dat),
				   version 'N' 22, 1200 bytes
22-cdrt-root.dat:                  RIFF (little-endian) data,
				   Corel Draw Picture template
				   (root.dat),
				   version 'R' 22, 1200 bytes
22-pat-root.dat:                   RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version 'G' 22, 1200 bytes
a5-v8.pat:                         RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version '8' 8, 5318 bytes
BANK_BC.CDT:                       RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'T' 4.4, 47924 bytes
bird-v10.pat:                      RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version 'A' 10, 61892 bytes
BRICKS2.PAT:                       RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version '4' 4.4, 11592 bytes
card-v8b.pat:                      RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version '8' 8.1, 16092 bytes
CLOUD063.CDR:                      RIFF (little-endian) data,
				   Corel Draw Picture,
				   version '4' 4.4, 10910 bytes
coreldraw13-pat-v7.pat:            RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version '7' 7, 5270 bytes
coreldraw13-v10.cdt:               RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version 'A' 10, 12372 bytes
coreldraw13-v11.cdt:               RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version 'B' 11, 12368 bytes
coreldraw13-v12.0.cdt:             RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version 'C' 12, 12742 bytes
coreldraw13-v13.cdt:               RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version 'D' 13, 12754 bytes
coreldraw13-v7.cdt:                RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '7' 7, 12176 bytes
coreldraw13-v80.cdt:               RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '8' 8, 12198 bytes
coreldraw13-v8bidi.cdt:            RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '8' 8.1, 12208 bytes
coreldraw13-v9.cdt:                RIFF (little-endian) data,
				   Corel Draw Picture or template,
				   version '9' 9, 12278 bytes
CORELDRW.CDT:                      RIFF (little-endian) data,
				   Corel Draw Picture template,
				   version 'E' 13, 1450 bytes
glas-v9.pat:                       RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version '9' 9, 10848 bytes
HAMSHARK.CCX:                      RIFF (little-endian) data,
				   Corel Clipart, 25544 bytes
heart-v11.pat:                     RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version 'B' 11, 239746 bytes
pat-v12.pat:                       RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version 'C' 12, 5838 bytes
pat-v13.pat:                       RIFF (little-endian) data,
				   Corel Draw Pattern,
				   version 'D' 13, 532828 bytes

I hope my diff file can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
--
Jörg Jenderek























-------------- next part --------------
--- file-5.38/magic/Magdir/riff.old	2019-04-19 01:42:27 +0000
+++ file-5.38/magic/Magdir/riff	2020-06-04 21:59:36 +0000
@@ -121,9 +121,31 @@
 >>12    string  >\0
 >>>12   use     riff-walk
+# Update:	Joerg Jenderek
+# lower case for Corel Draw version 8 Bidi
+>8	string/c	cdr
+# skip Corel CCX Clipart
+>>8	string		!CDRXcont
 # Corel Draw Picture
->8	string		CDRA		\b, Corel Draw Picture
-!:mime	image/x-coreldraw
->8	string		CDR6		\b, Corel Draw Picture, version 6
-!:mime	image/x-coreldraw
+>>>0	use     corel-draw
+# URL:		http://fileformats.archiveteam.org/wiki/CCX_(Corel)
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/c/ccx-corel.trid.xml 
+>>8	string		=CDRXcont	\b, Corel Clipart
+!:mime	application/x-corel-ccx
+!:ext	ccx
+# 3rd chunk data {Corel\040Binary\040Meta\040File}
+#>>>20	string		x		\b, 3rd '%-s'
+>>>4	ulelong+8	x		\b, %u bytes
+# From:		Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/CorelDRAW
+# Reference:	http://fileformats.archiveteam.org/wiki/CorelDRAW
+# Picture templates created by newer software start with RIFF type CDT
+>8	string		CDT
+>>0	use		corel-draw
+# Picture templates with version 4.4
+>8	string		CDST
+>>0	use		corel-draw
+# pattern created by newer software start with RIFF type PAT
+>8	string		PAT
+>>0	use		corel-draw
 >8	string		NUNDROOT	\b, Steinberg CuBase
 # AVI == Audio Video Interleave
@@ -256,5 +278,85 @@
 !:mime	image/webp
 >>12	use		riff-walk
-
+# From:		Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/CorelDRAW
+# Reference:	http://fileformats.archiveteam.org/wiki/CorelDRAW
+# Note:		Since version 3 CorelDraw Pictures are RIFF based
+# but data chunks remain proprietary.
+# Since version 14 til 15 packed as "content/riffData.cdr" and
+# since 16 "content/root.dat" in ZIP container
+# TODO:		distinguish templates with version 12.5 from Designer illustration 12
+#	display information of RIFF based Corel Draw pictures, templates and patterns
+0	name   	corel-draw
+# display second chunk for debugging
+#>8	string		x		\b, [8]=%.8s
+>0	string		x		\b, Corel Draw
+#!:mime	image/x-coreldraw
+!:mime	application/vnd.corel-draw
+# used by newer pictures templates
+>>8	string		CDT
+# used by templates with newer versions since 16
+>>>12	string		=fver		Picture template (root.dat)
+!:ext	dat
+# used by templates with older versions with vrsn tag
+>>>12	string		!fver
+# used by templates with older versions 14-15
+>>>>11	string		>E		Picture template (riffData.cdr)
+!:ext	cdr
+# used by templates with older versions 11-13
+>>>>11	string		<F		Picture template
+!:ext	cdt/cdrt
+# used by older templates with version 4.4
+>>8	string		CDST		Picture template
+!:ext	cdt
+# used by templates with version 12.5
+>>8	string		DESC		Picture template
+!:ext	cdt
+# used by newer patterns with version 22
+>>8	string		PAT		Pattern
+!:ext	dat
+# remaining older templates, patterns, drawings
+>>8	default		x
+# pattern with old version 4.y
+>>>26	ulelong		=0x0000206C	Pattern
+!:ext	pat
+# pattern with newer versions
+>>>26	ulelong		=0x00000D2C	Pattern
+!:ext	pat
+# remaining older templates or pictures
+>>>26	default		x
+# used by older versions 5 - 15
+>>>>12	string		=vrsn
+# 4th chunk size unequal 282Ch only found for CDR
+>>>>>26	ulelong		!0x0000282c	Picture
+!:ext	cdr
+>>>>>26	default		x		Picture or template
+!:ext	cdr/cdt
+# used by newer versions since 16
+>>>>12	string		=fver		Picture (root.dat)
+!:ext	dat
+# version marked by 1 ASCII char: space~3, ... , F~15,  ... , N~22, ... R~22 template
+>11	string		x		\b, version
+>11	string		>\040		'%-.1s'
+>0	use		corel-version
+>4	ulelong+8	x		\b, %u bytes
+#
+#	display numeric version of RIFF based Corel after 3rd RIFF tag
+0	name   	corel-version
+# for debugging purpose; vrsn for short content; fver for 16 byte size
+#>12	string		x		\b, TAG "%-4.4s"
+# 1st data chunk length 2 implies short content version
+>16	ulelong		2
+# vrsn chunk short content interpreted by MajorVersion * 100 + MinorVersion
+>>20	uleshort/100	x		%u
+>>20	uleshort%100	>0		\b.%u
+# for debugging purpose display next chunk like: DISP LIST
+#>>22	string		x		\b, 4th "%-4.4s"
+#>>26	ulelong		x		\b, 4th SIZE 0x%x
+# for debugging purpose display 5th chunk like: LIST DISP ccmm osfp
+#>>(26.l+30)	string	x		\b, 5th "%-4.4s"
+# 1st data chunk length 10h implies 16 byte content with version info
+>16	ulelong		0x10
+>>34	ubyte		x		%u
+>>>33	ubyte		>0		\b.%u
 #
 # XXX - some of the below may only appear in little-endian form.
@@ -293,7 +395,10 @@
 >>22	beshort		>2		\b, %d channels
 >>24	belong		>0		%d Hz
-# Corel Draw Picture
->8	string		CDRA		\b, Corel Draw Picture
->8	string		CDR6		\b, Corel Draw Picture, version 6
+# Corel Draw Picture big endian not tested by real examples
+#>8	string		CDRA		\b, Corel Draw Picture
+#>8	string		CDR6		\b, Corel Draw Picture, version 6
+>8	string		CDR
+>>0	use     \^corel-draw
+
 # AVI == Audio Video Interleave
 >8	string		AVI\040		\b, AVI


More information about the File mailing list