[File] [PATCH] of Magdir/images for Corel Photo-Paint image *.cpt

Christos Zoulas christos at zoulas.com
Tue Jun 23 16:15:08 UTC 2020


Committed, thanks!

christos

> On Jun 22, 2020, at 7:11 PM, Jörg Jenderek <joerg.jen.der.ek at gmx.net> wrote:
> 
> -----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-----
> <file-5_39-images-ptr_diff.DEFANGED-6129><file-5_39-images-cpt_diff.DEFANGED-6130><file-5_39-images-ptr_diff_sig.DEFANGED-6131><file-5_39-images-cpt_diff_sig.DEFANGED-6132>--
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file
> <sanitizer.log>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20200623/4e24aad1/attachment.asc>


More information about the File mailing list