[File] [PATCH] of Magdir/images for Corel Photo-Paint image *.cpt
Jörg Jenderek
joerg.jen.der.ek at gmx.net
Mon Jun 22 23:11:53 UTC 2020
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
some days ago i send patches for Corel files.
Now i also run file command version 5.39 on Corel Photo-Paint images
with file name extension cpt and some OS/2 pointer bitmaps with
extension ptr. With -m Magdir/images option i get an output like:
100x30dpi400.cpt: OS/2, hotspot 17740x1,
cbSize 1229338964, bits offset 0
30x10dpi72.cpt: OS/2, hotspot 17740x12,
cbSize 1229338964, bits offset 0
butrfly.cpt: OS/2, hotspot 17740x1,
cbSize 1229338964, bits offset 0
comment-utf.cpt: OS/2, hotspot 17740x1,
cbSize 1229338964, bits offset 0
comment.cpt: OS/2, hotspot 17740x1,
cbSize 1229338964, bits offset 0
concret5.cpt: OS/2, hotspot 17740x5,
cbSize 1229338452, bits offset 0
drawX8-bw150dpi.cpt: OS/2, hotspot 17740x6,
cbSize 1229338964, bits offset 0
drawX8-cmyk4800dpi.cpt: OS/2, hotspot 17740x3,
cbSize 1229338964, bits offset 0
drawX8-cpt7-8.cpt: OS/2, hotspot 17740x1,
cbSize 1229338452, bits offset 0
drawX8-rgbidpi600.cpt: OS/2, hotspot 17740x10,
cbSize 1229338964, bits offset 46399488
lightning.cpt: OS/2, hotspot 17740x5,
cbSize 1229338964, bits offset 0
PaintedBrick.cpt: OS/2, hotspot 17740x14,
cbSize 1229338964, bits offset 0
photopaint7-8.cpt: OS/2, hotspot 17740x1,
cbSize 1229338452, bits offset 0
Sample1.cpt: OS/2, hotspot 17740x1,
cbSize 1229338964, bits offset 0
WOOD23M.CPT: OS/2, hotspot 17740x10,
cbSize 1229338964, bits offset 50331648
os22-64.ptr: OS/2 2.x color pointer 32 x 32,
hotspot 16x16, cbSize 78, bits offset 164
SIZENWSE.PTR: OS/2 1.x color pointer 32 x 32,
hotspot 3x27, cbSize 26, bits offset 106
All such inspected Corel samples are misidentified as OS/2 color
pointers, because such files start with magic string like CPT9FILE.
This match also starting string CP of OS/2 color pointers with two
test lines inside Magdir/images like:
0 string CP
>14 ulelong <65 OS/2
By second line CPU-Z Report are skipped by checking for valid dib
header sizes 12 or 64. Unfortunately these 2 tests are non unique
enough and does not reach 32 bit significance. So i look for more
additional test conditions. The bits offset values describes the
offset to bitmap data (pixel array). For real OS/2 pointer files we
find typical values like 6Ah, A4h, E4h or 4A4h.
So skip many Corel Photo-Paint images by checking for positive bits
offset by additional test line
>10 ulelong >0
Furthermore i encapsulate the displaying part inside subroutine
os2-ptr. So second test becomes third test which is now looking like
>>14 ulelong =12
>>>0 use os2-ptr
>>14 ulelong =64
>>>0 use os2-ptr
After applying the above mentioned modifications by patch
file-5.39-images-ptr.diff then misidentification of Corel Photo-Paint
images vanish and OS/2 pointers are still recognized.
Some information can be found on file formats archive team site. So
i add a comment line like:
# http://fileformats.archiveteam.org/wiki/Corel_Photo-Paint_image
Some reversed engineered information with a few mistakes is found
in Corel PHOTO-PAINT CPT file format specification. This is
expressed by reference comment line like
# http://blog.argasinski.eu/
# wp-content/uploads/2011/08/cpt-specification-0.01.pdf
The Corel file start with magic string like CPT9FILE or CPT7FILE,
where digit is interpreted as version number. This is now expressed
by additional magic lines like
0 string CPT
>4 string FILE Corel Photo-Paint image, version
>>3 ubyte x %c,
Afterwards show user defined mime type and file name extension by
lines like:
!:mime image/x-corel-cpt
!:ext cpt
Also show positive number of CPT blocks with optional plural s by
lines like
>>0x28 ulelong x \b, %u block
>>0x28 ulelong !1 \bs
I also show offset (typical values like: 13Ch 154h 43Ch 4F0h DA8h)
to array with block objects by line like
>>0x34 ulelong x \b, array offset 0x%x
But this is zero for for CPT7 and CPT8 files created by PP7-PP8.
After this varying part comes first object block. The work is jump
to that block and show width and height stored at the beginning of
that block. If array offset is not zero jump blockNumber*8 bytes
forward.
Then jump additional stored array_offset bytes forward to object
block and show images dimension. This is done by lines like:
>>0x34 ulelong >0
>>>(0x28.l*8) ubyte x
>>>>&(0x34.l-1) ulelong x %u
>>>>>&0 ulelong x x %u
Do also similar procedure for cases with zero array offset.
Afterward show used color model with color depth information by
lines starting like:
>>0x8 ulelong x
>>>0x8 ulelong 0x1 RGB 24 bits
>>>0x8 ulelong 0x3 CMYK 24 bits
...
The CPT file flags are apparently stored offset 0x30 and not at
0x32 as mentioned in PDF document. So show the flag value for
unexpected cases by lines like:
>>0x31 ubyte&0xFC >0
>>>0x30 uleshort x \b, flags 0x%4.4x
If bit 1 in CPT file flags is set, then a UCS-2 file comment is
present. The start of the position varying comment seems to be
marked by 4 byte sequence \4\2\0\0. So show this comment by lines lik
e:
>>0x31 ubyte &0x02
>>>0x100 search/0xc9d \4\2\0\0
>>>>&0 lestring16 x "%s"
If no UCS-2 comment is present then show ANSI file comment with
maximal 112 characters if available by lines:
>>0x31 ubyte&0x02 =0
>>>0x3C string >\0 "%-.112s"
After applying the above mentioned modifications by patch
file-5.39-images-cpt.diff then i get a correct describing output like
:
100x30dpi400.cpt: Corel Photo-Paint image, version 9,
100 x 30 RGB 24 bits,
15748031 micro dots/mm,
1 block, array offset 0xb9854,
with ICC profile
30x10dpi72.cpt: Corel Photo-Paint image, version 9,
30 x 10 RGB 48 bits,
2834646 micro dots/mm,
1 block, array offset 0x13c
butrfly.cpt: Corel Photo-Paint image, version 9,
824 x 192 RGB 24 bits,
3779528 micro dots/mm,
4 blocks, array offset 0x13c
comment-utf.cpt: Corel Photo-Paint image, version 9,
764 x 629 RGB 24 bits
"umlaut test: ä=ae ö=oe ü=ue ß=ss ¬=euro",
5669291 micro dots/mm,
2 blocks, array offset 0x358,
with ICC profile
comment.cpt: Corel Photo-Paint image, version 9,
764 x 629 RGB 24 bits
"this is a comment",
5669291 micro dots/mm,
2 blocks, array offset 0x358,
with ICC profile
concret5.cpt: Corel Photo-Paint image, version 7,
318 x 238 greyscale 8 bits,
3779528 micro dots/mm,
1 block, array offset 0x0
drawX8-bw150dpi.cpt: Corel Photo-Paint image, version 9,
434 x 389 black and white 1 bit,
5905511 micro dots/mm,
2 blocks, flags 0x0594, array offset 0x4f0,
reserved5 0x7a08, with ICC profile
drawX8-cmyk4800dpi.cpt: Corel Photo-Paint image, version 9,
CMYK 24 bits,
188976377 micro dots/mm,
2 blocks, flags 0x0594, array offset 0x1bea35
reserved5 0x25a66c9, with ICC profile
drawX8-cpt7-8.cpt: Corel Photo-Paint image, version 7,
1549 x 1762 RGB 24 bits
"drawX8-13", 11811023 micro dots/mm,
2 blocks, array offset 0x13c,
reserved5 0x67310
drawX8-rgbidpi600.cpt: Corel Photo-Paint image, version 9,
1735 x 1556 RGB 8 bits, 236 colors,
23622047 micro dots/mm,
2 blocks, flags 0x0494, array offset 0x40c,
reserved5 0x32134c
lightning.cpt: Corel Photo-Paint image, version 9,
2000 x 2000 greyscale 8 bits,
11811024 micro dots/mm,
2 blocks, array offset 0x13c
PaintedBrick.cpt: Corel Photo-Paint image, version 9,
320 x 320 greyscale 16 bits,
2834646 micro dots/mm,
2 blocks, array offset 0x13c
photopaint7-8.cpt: Corel Photo-Paint image, version 7,
1143 x 54 RGB 24 bits,
11811023 micro dots/mm,
2 blocks, array offset 0x13c
Sample1.cpt: Corel Photo-Paint image, version 9,
480 x 672 RGB 24 bits "530069",
3779528 micro dots/mm,
33 blocks, array offset 0x13c
WOOD23M.CPT: Corel Photo-Paint image, version 9,
320 x 256 RGB 8 bits,
11811024 micro dots/mm,
2 blocks, array offset 0x43c
os22-64.ptr: OS/2 2.x color pointer 32 x 32,
hotspot 16x16, cbSize 78, bits offset 164
SIZENWSE.PTR: OS/2 1.x color pointer 32 x 32,
hotspot 3x27, cbSize 26, bits offset 106
I hope my 2 diff files can be applied in future version of
file utility.
With best wishes
Jörg Jenderek
- --
Jörg Jenderek
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXvE6kwAKCRCv8rHJQhrU
1ugHAKDZ49KLY2jzdUgUpBRh8AE55OvCrACePbH13QVHUqYQpNA1aiDWmr6HaNQ=
=tHvI
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.39/magic/Magdir/images.old 2020-05-31 10:34:40 +0000
+++ file-5.39/magic/Magdir/images 2020-06-22 22:51:12 +0000
@@ -798,8 +798,16 @@
# URL: http://fileformats.archiveteam.org/wiki/OS/2_Pointer
# Reference: http://www.fileformat.info/format/os2bmp/egff.htm
0 string CP
+# skip many Corel Photo-Paint image "CPT9FILE" by checking for positive bits offset
+>10 ulelong >0
# skip CPU-Z Report by checking for valid dib header sizes 12 or 64
->14 ulelong <65 OS/2
+>>14 ulelong =12
+>>>0 use os2-ptr
+>>14 ulelong =64
+>>>0 use os2-ptr
+# display information of OS/2 pointer bitmaps
+0 name os2-ptr
+>14 ulelong x OS/2
# http://extension.nirsoft.net/PTR
!:mime image/x-ibm-pointer
!:ext ptr
-------------- next part --------------
--- file-5.39/magic/Magdir/images.old 2020-05-31 10:34:40 +0000
+++ file-5.39/magic/Magdir/images 2020-06-22 22:56:46 +0000
@@ -2567,3 +2567,92 @@
>4 byte 0 Apple QuickTake 150 Raw Image
>4 byte >0 Apple QuickTake 200 Raw Image
>0 use quicktake
+
+# From: Joerg Jenderek
+# URL: http://fileformats.archiveteam.org/wiki/Corel_Photo-Paint_image
+# Reference: http://blog.argasinski.eu/wp-content/uploads/2011/08/cpt-specification-0.01.pdf
+0 string CPT
+>4 string FILE Corel Photo-Paint image, version
+# version like 7, 9 or 8
+>>3 ubyte x %c,
+!:mime image/x-corel-cpt
+!:ext cpt
+# if blocks_array_offset available jump blockNumber*8 bytes
+>>0x34 ulelong >0
+>>>(0x28.l*8) ubyte x
+# jump addtional stored blocks_array_offset bytes forward to object block
+>>>>&(0x34.l-1) ulelong x %u
+# object heigth in pixels
+>>>>>&0 ulelong x x %u
+# if no blocks_array_offset available jump blockNumber*8 bytes
+>>0x34 ulelong =0
+>>>(0x28.l*8) ubyte x
+# jump addtional 0x13C bytes forward to object block
+>>>>&0x13B ulelong x %u
+>>>>>&0 ulelong x x %u
+# image color model used
+>>0x8 ulelong x
+>>>0x8 ulelong 0x1 RGB 24 bits
+>>>0x8 ulelong 0x3 CMYK 24 bits
+>>>0x8 ulelong 0x5 greyscale 8 bits
+>>>0x8 ulelong 0x6 black and white 1 bit
+>>>0x8 ulelong 0xA RGB 8 bits
+# palette_length number of colors * 3 in case of 8-bit RGB paletted image
+# 0 otherwise. Allowed values: 0 or [1..256] * 3
+#>>0xC ulelong >0 \b, palette length %u
+>>>>0xC ulelong/3 <256 \b, %u colors
+>>>0x8 ulelong 0xB LAB
+>>>0x8 ulelong 0xC RGB 48 bits
+>>>0x8 ulelong 0xE greyscale 16 bits
+# this should not happen
+>>>0x8 default x color model
+>>>>0x8 ulelong x 0x%x
+# bit 1 in CPT file flags: UCS-2 file comment present
+>>0x31 ubyte &0x02
+# look for comment marker
+>>>0x100 search/0xc9d \4\2\0\0
+# UCS-2 file comment
+>>>>&0 lestring16 x "%s"
+# if no UCS-2 is present show ANSI file comment[112] if available
+>>0x31 ubyte&0x02 =0
+>>>0x3C string >\0 "%-.112s"
+# reserved seems to be always 0
+#>>0x10 ulelong >0 \b, reserved1 %u
+# horizontal real dpi = dpi_h * 25.4 / 10**6
+>>0x18 ulelong x \b, %u micro dots/mm
+# image vertical DPI in CPT DPI unit
+#>>0x1C ulelong x \b, %u micro dots/mm
+# reserved seems to be always 0
+#>>0x20 ulelong >0 \b, reserved2 %u
+#>>0x24 ulelong >0 \b, reserved3 %u
+# blocks_count; number of CPT_Block blocks. Allowed values: > 0
+>>0x28 ulelong x \b, %u block
+# plural s
+>>0x28 ulelong !1 \bs
+# CPT file flags
+# lower byte of CPT file flags: 0x94~CPT9FILE 0x01~often CPT7FILE 0x8C~CPT8FILE
+#>>0x30 ubyte x \b, lower flags 0x%x
+# upper byte of CPT file flags:
+#>>0x31 ubyte >0 \b, upper flags 0x%x
+# bit 2 in CPT file flags: unknown
+#>>0x31 ubyte &0x04 \b, with UNKNOWN
+# bits 3-7 in CPT file flags: unknown, seem to be often 0
+# show unusual flag combinations
+>>0x31 ubyte&0xFC >0
+>>>0x30 uleshort x \b, flags 0x%4.4x
+# reserved seems to be always 0
+#>>0x32 uleshort >0 \b, reserved4 0x%x
+# blocks_array_offset is always 0 for CPT7 and CPT8 files created by PP7-PP8
+# typical values like: 13Ch 154h 43Ch 4F0h DA8h
+>>0x34 ulelong x \b, array offset 0x%x
+# reserved seems to be often 0
+>>0x38 ulelong >0 \b, reserved5 0x%x
+# possible next master block
+#>>0x100 ubequad !0 \b, next block=0x%llx...
+# bit 0: ICC profile block present
+>>0x31 ubyte &0x01 \b, with ICC profile
+# check for characteristic string acsp of color profile for DEBUGGING
+#>>>0x178 string x icc=%.4s
+# display ICC/ICM color profile by ./icc
+#>>>0x154 use color-profile
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.39-images-ptr.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200623/2c50cb31/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.39-images-cpt.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200623/2c50cb31/attachment-0001.obj>
More information about the File
mailing list