[File] [PATCH] Magdir/printer Hewlett-Packard Graphics Language *.hpgl *.hpg *.plt *.hp

Jörg Jenderek joerg.jen.der.ek at gmx.net
Fri Dec 16 02:27:16 UTC 2022


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

some weeks ago i update my inkscape graphic software. Just for
interest i looked what file formats it now can open, export or import
.

One listed extension is HPGL. So i looked for such samples.
When running file command version 5.43 on such samples and related
files i get an output like:

286x192.5_lq.hpg:      data
MyCD.hpgl:             ASCII text, with very long lines (4928)
		       , with no line terminators
cdraw2020-plt.plt:     ASCII text, with CRLF line terminators
charsize.hp:           data
ci.hp:                 ASCII text
corbusie.hpg:          ASCII text, with very long lines (65536)
		       , with no line terminators
coreldraw2019-plt.plt: ASCII text, with CRLF line terminators
ew.hpg:                ASCII text
fill.plt:              data
input.hpgl:            ASCII text, with very long lines (65536)
		       , with no line terminators
miter.hp:              ASCII text
pw.hpg:                ASCII text
test.hpgl:             data
test1.hpgl:            ASCII text
test3.hpgl:            data
thick.hp:              ASCII text
ul.hp:                 data
win_1.hp:              data

With option --extension 3 byte sequence ??? is shown and with
option -i only generic text/plain or application/octet-stream
mime types are shown.

For comparison reason i run the file format identification utility
TrID ( See https://mark0.net/soft-trid-e.html). This identifies
one third of my examples as "Hewlett-Packard Graphics Language" by
hpg.trid.xml. But one third of my examples ( like  charsize.hp ci.hp
fill.plt pw.hpg test1.hpgl win_1.hp) are not described. And some
examples ( like 286x192.5_lq.hpg ew.hpg thick.hp ul.hp) starting with
upcase letter B or P are described wrong as "PrintFox/Pagefox bitmap"
by bitmap-printfox-p.trid.xml or bitmap-printfox-s.trid.xml. One
example test3.hpgl is described wrong as "Spectrum emulator snapshot"
by sp-spectrum.trid.xml. TrID mentions only 2 suffix (HPGL/HPG) and a
user defined mime type vector/x-hpgl. For "Hewlett-Packard Graphics
Language 2" it mention only 4 suffix (GL2/HPG2/PLT/SPL) and mime type
application/vnd.hp-HPGL (See appended trid-v-hpgl.txt.gz).

For comparison reason i also run the file format identification
utility DROID ( See https://sourceforge.net/projects/droid/). The
PLT samples are described as "Hewlett Packard Vector Graphic Plotter
File" by PUID x-fmt/83. The HPGL samples are described as "Hewlett
Packard Graphics" by PUID x-fmt/293. Here the official registered
mime type application/vnd.hp-HPGL is shown (See appended
droid-hpgl.csv.gz).

All samples can be viewed, converted or at least inspected by graphic
tool Xnview (See appended nconvert-hpgl.txt.gz). This can be verified
by command line like:
	nconvert -in hpgl -info *

Luckily with information given by other tools i also found page about
HP-GL on Wikipedia and on file formats archive team. There i also
find samples for download and suited software. That informations are
now expressed by comment lines inside Magdir/printer like:
# URL:		http://fileformats.archiveteam.org/wiki/HP-GL
#		https://en.wikipedia.org/wiki/HPGL
# Reference:	http://mark0.net/download/triddefs_xml.7z
#		defs/h/hpg.trid.xml
#		defs/h/hpgl2.trid.xml

Obviously the Hewlett-Packard Graphics have no unique magic pattern.
So i put displaying part inside sub routine which starts with line
like:
 0	name			hpgl
 >0	string	x		Hewlett-Packard Graphics Language
 !:mime	application/vnd.hp-HPGL
 !:ext	hpgl/hpg/hp/plt
Instead of user defined mime type i use the official registered one,
that is also used by DROID. According to documentation the samples
contain TEXT with instructions for HP plotter. The documentation
mention 4 suffix, but i do not found samples with HPL extension.
But i found some examples with HP extensions.

So many samples are described by current magic as ASCII text and
some samples are described as data because these contain
Control-characters like ^C or escape sequences but normally not at
the beginning. So for informational and control reason i show
content at the beginning by lines like:
 >0	string	x			\b, starting with "%-.54s"
 >>&0	ubyte	<0x0E
 >>>&0	string	>\r			with "%-.10s"
 >>>&0	ubyte	<0x0E
 >>>>&0	string	>\r			with "%-.10s"

For the samples described by TrID i get as starting line something
like:
"IN;PU;SP1;PU0,0;PD0,90;
So if you are an HP graphic expert you see that this is a valid HPGL
file, which starts with initialize plotting job instruction IN. In
some examples (like MyCD.hpgl corbusie.hpg input.hpgl) indicated by
phrase ", with no line terminators" all instructions apparently are
written in one line. On the other hand in some examples (like
cdraw2020-plt.plt coreldraw2019-plt.plt created by CorelDraw) every
instruction is placed on an own line. Here also carriage return and
line feed (indicated by phrase "with CRLF line terminators" are used
as line separators whereas for other examples only line feed is used
as line separator. So for the CorelDraw examples i get first only
phrase 'starting with "IN;"'. So here only 3 characters are shown.
According to recommendation 4 bytes should be used for recognition.
Then of course for control reasons then 4 or more characters should
be shown. So i show content of second line by the last constructs
starting by phrase "with".

Now i can put parts together. For the samples recognized by TrID
these start with initializing plot job instruction. So this looks lik
e:
 0	string	IN;
 >0		use		hpgl
The sample test3.hpgl start with select pen directive SP. So this is
done by line like:
 0	string	SP
 >0		use		hpgl
Then i add for samples (like iw.hp 286x192.5_lh.hpg
286x192.5_lq.hpg) lines like:
 0	string	PS\040
 >0		use		hpgl
I do not know what this means, because i have not time to read whole
specification and get part time HP plotter expert. Furthermore i use
lower than 4 bytes for recognition. That is not nice but if there
exist collisions with other samples than just more test lines must
be added. So at the moment things works as expected.

For samples described as "2" variant like sample dt.plt which start
with escape like string are now described by lines like:
0	string	\033%-1B		Hewlett-Packard Graphics Language 2
!:mime	application/vnd.hp-HPGL
!:ext	plt
> 5	string	x			with "%-.10s"

After applying the above mentioned modifications by patch
file-5.43-printer-hpgl.diff then most of my Hewlett-Packard
Graphics samples are now detected and described. This now looks like:

286x192.5_lq.hpg:      Hewlett-Packard Graphics Language,
		       starting with "PS 11440 7700"
		       with "IP 0 0 114"
MyCD.hpgl:             Hewlett-Packard Graphics Language,
		       starting with "IN;PU;SP1;PU0,0;PD0,90;
		       PU2410,4820;PD2405,4819,2401,48"
cdraw2020-plt.plt:     Hewlett-Packard Graphics Language,
		       starting with "IN;"
		       with "VS32,1;\01"
charsize.hp:           Hewlett-Packard Graphics Language,
		       starting with "IP0,0,1000,1000;"
		       with "SR3.33333,"
ci.hp:                 Hewlett-Packard Graphics Language,
		       starting with "CO Concentric circles
		       drawn with different linewidths;"
		       with "PU 500,500"
corbusie.hpg:          Hewlett-Packard Graphics Language,
		       starting with "IN;SC;
		       IW-16820,-11880,16820,11880;
		       VS25;SP1;LT;PU;PA-76"
coreldraw2019-plt.plt: Hewlett-Packard Graphics Language,
		       starting with "IN;"
		       with "VS32,1;\01"
dt.plt:                Hewlett-Packard Graphics Language 2
		       with "BPINPS1117"
ew.hpg:                Hewlett-Packard Graphics Language,
		       starting with "BP"
		       with "IN\012PS70"
fill.plt:              Hewlett-Packard Graphics Language,
		       starting with "INPS20000,20000"
		       with "IW2000,200"
input.hpgl:            Hewlett-Packard Graphics Language,
		       starting with "IN;SP1;CA7;PU3598,4271;
		       PD673,4271,673,7197,;PU3598,425"
miter.hp:              Hewlett-Packard Graphics Language,
		       starting with "PA4000,3000;" with "
		       PW2;\012LA"
pw.hpg:                Hewlett-Packard Graphics Language,
		       starting with "NP8;"
		       with "PW 0.13, 1"
test.hpgl:             Hewlett-Packard Graphics Language,
		       starting with "IN;SP3;DI0,1;
		       SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA"
test1.hpgl:            Hewlett-Packard Graphics Language,
		       starting with "DF;IN;LT;PU1000,1000;
		       PD2000,1000,2000,2000,1000,2000,1"
		       with "PR-100,0,0"
test3.hpgl:            Hewlett-Packard Graphics Language,
		       starting with "SP6;DI0,1;SR0.70,1.90;
		       SC0,800,0,576;PA;PU20,0;LBDSA 60"
		       with "SP3;SC-864"
thick.hp:              Hewlett-Packard Graphics Language,
		       starting with "PS9600,7100"
		       with "LT-4,50,1\"
ul.hp:                 Hewlett-Packard Graphics Language,
		       starting with "PS4600,2100"
		       with "IP0,0,4600"
win_1.hp:              data

With best wishes,

Jörg Jenderek
- --
Jörg Jenderek









-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCY5vXhAAKCRCv8rHJQhrU
1r/AAKDJlTdvRRjqUpI7HG5YB1eHIqJGRgCffkGVtgl5b24GQIDoAQALv90B7Fw=
=HzWC
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: droid-hpgl.csv.gz
Type: application/x-gzip
Size: 772 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20221216/ffdbd11a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trid-v-hpgl.txt.gz
Type: application/x-gzip
Size: 754 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20221216/ffdbd11a/attachment-0001.bin>
-------------- next part --------------
--- file-5.43/magic/Magdir/printer.old	2021-02-23 01:49:24.000000000 +0100
+++ file-5.43/magic/Magdir/printer	2022-12-16 02:54:59.354917000 +0100
@@ -148,3 +148,82 @@
 # From: Paolo <oopla at users.sf.net>
 # Epson ESC/Page, ESC/PageColor
 0	string	\x1b\x01 at EJL	Epson ESC/Page language printer data
+
+# Summary:	Hewlett-Packard Graphics Language
+# From:		Joerg Jenderek
+# URL:		http://fileformats.archiveteam.org/wiki/HP-GL
+#		https://en.wikipedia.org/wiki/HPGL
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/h/hpg.trid.xml
+# Note:		called "Hewlett-Packard Graphics Language" by TrID and
+#		"Hewlett Packard Graphics Language" by DROID via PUID x-fmt/293 and
+#		HPGL by XnView command `nconvert -info *`
+# initialize, start a plotting job 
+0	string	IN;
+>0		use		hpgl
+# fill.plt
+0	string	INPS
+>0		use		hpgl
+# http://ftp.funet.fi/index/graphics/packages/hpgl2ps/hpgl2ps.tar.Z/hpgl2ps/test1.hpgl 
+0	string	DF;
+>0		use		hpgl
+# http://ftp.funet.fi/index/graphics/packages/hpgl2ps/hpgl2ps.tar.Z/hpgl2ps/test3.hpgl 
+# Select Pen n
+0	string	SP
+>0		use		hpgl
+# charsize.hp pages.hp	set the scaling points (P1 and P2) to their default positions
+0	string	IP0
+>0		use		hpgl
+# ci.hp
+0	string	CO\040
+>0		use		hpgl
+# iw.hp 286x192.5_lh.hpg 286x192.5_lq.hpg
+0	string	PS\040
+>0		use		hpgl
+# thick.hp
+0	string	PS9
+>0		use		hpgl
+# ul.hp
+0	string	PS4
+>0		use		hpgl
+# la.hp
+0	string	BP
+>0		use		hpgl
+# miter.hp
+0	string	PA
+>0		use		hpgl
+# pw.hpg	number of pens x
+0	string	NP
+>0		use		hpgl
+# win_1.hp
+#0	string	\003INCA		WHAT_IS_THAT
+#>0		use		hpgl
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/h/hpgl2.trid.xml
+# Note:		called "Hewlett-Packard Graphics Language 2" by TrID
+0	string	\033%-1B		Hewlett-Packard Graphics Language 2
+!:mime	application/vnd.hp-HPGL
+# like: dt.plt
+!:ext	plt
+#!:ext	plt/gl2/hpg2/spl
+# remaining part after escsape sequnce
+>5	string	x			with "%-.10s"
+#	display Hewlett-Packard Graphics Language vector graphic information
+0	name				hpgl
+>0	string	x			Hewlett-Packard Graphics Language
+#!:mime	vector/x-hpgl
+# https://www.iana.org/assignments/media-types/application/vnd.hp-HPGL
+!:mime	application/vnd.hp-HPGL
+# no example with HPL suffix found
+!:ext	hpgl/hpg/hp/plt
+# like: "IN;" "DF;IN;LT;PU1000,1000;PD2000,10" "SP6;DI0,1;SR0.70,1.90;SC0,800,"
+# "CO Concentric circles drawn with different linewidths;"
+>0	string	x			\b, starting with "%-.54s"
+# continue but not for 1 long line without CR or LF
+>>&0	ubyte	<0x0E
+#>>&0	ubyte	<0x0E			TERMINATOR=%x
+# second line after 1 terminator character
+>>>&0	string	>\r			with "%-.10s"
+# next character again CR or LF
+>>>&0	ubyte	<0x0E
+#>>>&0	ubyte	<0x0E			2ND_CHARACTER=%x
+# second line after 2 terminator characters
+>>>>&0	string	>\r			with "%-.10s"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.43-printer-hpgl.diff.sig
Type: application/octet-stream
Size: 1398 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20221216/ffdbd11a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nconvert-hpgl.txt.gz
Type: application/x-gzip
Size: 654 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20221216/ffdbd11a/attachment-0002.bin>


More information about the File mailing list