中二病が加速する!プログラムを魔法陣画像に変換するMystical使用例の補足

前回、PostScript ファイルを実行できる Ghostscript (Windows 版の gswin64c) で、mystical.ps を使用して PostScript のプログラムを魔法陣の画像に変換する際に -dNOSAFER, -sDEVICE, -sOutputFile オプションを用いた理由や、画像に変換するサンプルとして同梱の examples.ps が適していることなどについて、調べてわかったことを前回の記事の補足として紹介します。

※試しながらわかったことを記述している部分もあるので、我流の手順とその結果としてお読みください。

Mystical example.ps の魔法陣の画像が showpage によって GhostScript Image ウィンドウに表示されました。

※ gs10.05.1 を使用します。
※ 2025 年 05 月 24 日に GitHub で公開されている mystical_ps, dmmlib リポジトリの複製を使用しています。

前回の記事

前回は、プログラムを、関数や型に応じて、魔法陣の画像に変換する Mystical を Windows で実行する手順を紹介しました。

今回は、その際に紹介した以下のコマンドのオプションの必要性などについて説明します。

gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png mystical.ps examples.ps

訂正

紹介した以下のコマンドでも、魔法陣の画像をファイルに保存できます。

gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png mystical.ps examples.ps

しかし、examples.ps の内部で mystical.ps を用いているため、 mystical.ps を指定する必要はありませんでした

以下のコマンドで、Ghostscript Image ウィンドウに、生成した魔法陣の画像が表示できます。

gswin64c -dNOSAFER examples.ps

以下のコマンドで、生成した魔法陣の画像を output.png ファイルに保存できます。

gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png examples.ps

テストに用いるファイルは examples.ps を選択

examples/quicksort.ps ファイルから魔法陣の画像を作成しようと思い、以下のコマンドを実行しました。

gswin64c -dNOSAFER -sDEVICE=pngalpha -sOutputFile="output.png" mystical.ps examples/quicksort.ps

実行すると、エラーは起きませんでしたが、ファイルが出力されません

-dDEBUG オプションを付けて以下のコマンドを実行すると、詳細なログを出力しながら実行すると、最後の方で runEPS: Not DSC と表示されています。

gswin64c -dDEBUG -dNOSAFER -sDEVICE=pngalpha -sOutputFile="output.png" mystical.ps examples/quicksort.ps
g:\Dev\Mistical\mystical_ps-main\mystical_ps-main>gswin64c -dDEBUG -dNOSAFER -sDEVICE=pngalpha -sOutputFile="output.png" mystical.ps examples/quicksort.ps
START 0 1471344 173473 1310608 29620 true 556 3 <0>
GPL Ghostscript 10.05.1 (2025-04-29)
Copyright (C) 2025 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
END PROCS 0 1540376 228013 1330808 36140 true 665 3 <0>
END FONTDIR/ENCS 0 1548808 254022 1330808 38620 true 675 3 <0>
END DEVS 0 1588080 293507 1330808 38620 true 679 3 <0>
END STATD 15 1608280 310040 1330808 41500 true 684 3 <0>
END GS_FONTS 15 1687264 387970 1330808 41500 true 713 3 <0>
END BASIC COLOR 15 1707464 397271 1330808 41500 true 729 3 <0>
END IMAGE 15 1707464 404906 1330808 41500 true 734 3 <0>
BEGIN RESOURCES 15 2489984 1146885 1435912 147300 true 755 4 <0>
END CATEGORY 15 2489984 1150812 1435912 147588 true 756 5 <0>
END GENERIC 15 2499936 1171120 1435912 147588 true 758 4 <0>
END FIXED 15 2520136 1188331 1435912 147588 true 758 4 <0>
END MISC 15 2540336 1203347 1435912 147588 true 758 4 <0>
END ENCODING 15 2621136 1279945 1435912 151218 true 758 4 <0>
Extend MacRomanEncodingForTrueType for TrueType: insert /partialdiff @ 182
Extend MacRomanEncodingForTrueType for TrueType: insert /greaterequal @ 179
Extend MacRomanEncodingForTrueType for TrueType: insert /Delta @ 198
Extend MacRomanEncodingForTrueType for TrueType: insert /lessequal @ 178
Extend MacRomanEncodingForTrueType for TrueType: insert /infinity @ 176
Extend MacRomanEncodingForTrueType for TrueType: insert /integral @ 186
Extend MacRomanEncodingForTrueType for TrueType: cannot insert /Euro @ 219 used for /currency
Extend MacRomanEncodingForTrueType for TrueType: insert /apple @ 240
Extend MacRomanEncodingForTrueType for TrueType: insert /notequal @ 173
Extend MacRomanEncodingForTrueType for TrueType: insert /summation @ 183
Extend MacRomanEncodingForTrueType for TrueType: insert /approxequal @ 197
Extend MacRomanEncodingForTrueType for TrueType: insert /radical @ 195
Extend MacRomanEncodingForTrueType for TrueType: insert /lozenge @ 215
Extend MacRomanEncodingForTrueType for TrueType: insert /Omega @ 189
Extend MacRomanEncodingForTrueType for TrueType: insert /pi @ 185
Extend MacRomanEncodingForTrueType for TrueType: insert /product @ 184
END INITFILES 15 3323488 1958640 1435912 153296 true 1003 4 <0>
D:\ProgramFiles\gs10.05.1\bin/Fontmap 15 3343688 1965194 1456112 158566 true 1004 4 <1>
D:\ProgramFiles\gs10.05.1\lib/Fontmap 15 3384088 1997227 1456112 158566 true 1004 4 <1>
D:\ProgramFiles\gs10.05.1\fonts/Fontmap 15 3384088 2007166 1456112 158566 true 1004 4 <1>
%rom%Resource/Init/Fontmap 15 3404288 2020540 1456112 158566 true 1004 4 <1>
%rom%lib/Fontmap 15 3424488 2040280 1456112 158566 true 1004 4 <1>
c:/gs/gs10.05.1/Resource/Init/Fontmap 15 3444688 2053649 1456112 158566 true 1004 4 <1>
c:/gs/gs10.05.1/lib/Fontmap 15 3444688 2063576 1456112 158566 true 1004 4 <1>
c:/gs/gs10.05.1/Resource/Font/Fontmap 15 3464888 2076961 1456112 158566 true 1004 4 <1>
c:/gs/fonts/Fontmap 15 3485088 2090312 1456112 158566 true 1004 4 <1>
END FONTS 15 3485088 2100317 1456112 158566 true 1003 4 <0>
END DEVICE 15 3505288 2109600 1454168 156622 true 1006 4 <0>
END CONFIG 15 3505288 2109866 1454168 156622 true 1006 4 <0>
END INIT 31 3545688 2149122 2874240 1576398 true 1019 4 <0>
END GLOBAL 31 3545688 2153168 2874240 1578710 false 1018 4 <0>
END GC 31 3439768 1915269 2877512 1567890 false 756 3 <0>
runEPS: Not DSC
runEPS: Not DSC
runEPS: Not DSC
runEPS: Not DSC
runEPS: Not DSC
runEPS: Not DSC
resmp FindResource beg Zapf-Chancery
Querying operating system for font files...
cidcm GetCIDSystemInfo beg
resmp ResourceStatus beg /Zapf
resmp ResourceFileName beg Zapf
resmp ResourceFileName : have NO map record.
resmp ResourceFileName : retrieving %rom%Resource/CIDFont/Zapf
resmp ResourceFileName end
resmp ResourceStatus end
cidcm GetCIDSystemInfo end
cidcm GetCIDSystemInfo beg
resmp ResourceStatus beg /Zapf
resmp ResourceFileName beg Zapf
resmp ResourceFileName : have NO map record.
resmp ResourceFileName : retrieving %rom%Resource/CIDFont/Zapf
resmp ResourceFileName end
resmp ResourceStatus end
cidcm GetCIDSystemInfo end
resmp ResourceStatus beg /Zapf-Chancery
cidcm GetCIDSystemInfo beg
resmp ResourceStatus beg /Zapf
resmp ResourceFileName beg Zapf
resmp ResourceFileName : have NO map record.
resmp ResourceFileName : retrieving %rom%Resource/CIDFont/Zapf
resmp ResourceFileName end
resmp ResourceStatus end
cidcm GetCIDSystemInfo end
resmp ResourceStatus end
Can't find (or can't open) font file %rom%Resource/Font/%rom%Resource.
Can't find (or can't open) font file Zapf-Chancery.
Didn't find this font on the system!
Substituting font ZapfChancery-MediumItalic for Zapf-Chancery.
resmp FindResource beg ZapfChancery-MediumItalic
resmp ResourceStatus beg /ZapfChancery-MediumItalic
resmp ResourceStatus end
Loading Z003-MediumItalic font from %rom%Resource/Font/Z003-MediumItalic...
FAPIhook Z003-MediumItalic
FAPIhook is in .loadfont context for the font Font Z003-MediumItalic.
Trying to render the font Font Z003-MediumItalic with FAPI...
Font Z003-MediumItalic is being rendered with FAPI=FreeType
runEPS: Not DSC
3484832 2160703 3177240 1875831 1 done.

setting alias: /Kcedilla to be the same as glyph: /Kcommaaccent

setting alias: /Dzecyrillic to be the same as glyph: /afii10054

setting alias: /numero to be the same as glyph: /afii61352

setting alias: /Ldotaccent to be the same as glyph: /Ldot

setting alias: /kacyrillic to be the same as glyph: /afii10076

setting alias: /elcyrillic to be the same as glyph: /afii10077

setting alias: /emcyrillic to be the same as glyph: /afii10078

setting alias: /encyrillic to be the same as glyph: /afii10079

setting alias: /ocyrillic to be the same as glyph: /afii10080

setting alias: /escyrillic to be the same as glyph: /afii10083

setting alias: /tecyrillic to be the same as glyph: /afii10084

setting alias: /ucyrillic to be the same as glyph: /afii10085

setting alias: /Elcyrillic to be the same as glyph: /afii10029

setting alias: /efcyrillic to be the same as glyph: /afii10086

setting alias: /khacyrillic to be the same as glyph: /afii10087

setting alias: /tsecyrillic to be the same as glyph: /afii10088

setting alias: /iacyrillic to be the same as glyph: /afii10097

setting alias: /Lcedilla to be the same as glyph: /Lcommaaccent

setting alias: /Ostrokeacute to be the same as glyph: /Oslashacute

setting alias: /gheupturncyrillic to be the same as glyph: /afii10098

setting alias: /djecyrillic to be the same as glyph: /afii10099

setting alias: /blackuppointingtriangle to be the same as glyph: /triagup

setting alias: /ecyrillic to be the same as glyph: /afii10101

setting alias: /dzecyrillic to be the same as glyph: /afii10102

setting alias: /icyrillic to be the same as glyph: /afii10103

setting alias: /jecyrillic to be the same as glyph: /afii10105

setting alias: /ljecyrillic to be the same as glyph: /afii10106

setting alias: /njecyrillic to be the same as glyph: /afii10107

setting alias: /odblacute to be the same as glyph: /ohungarumlaut

setting alias: /tshecyrillic to be the same as glyph: /afii10108

setting alias: /Kacyrillic to be the same as glyph: /afii10028

setting alias: /checyrillic to be the same as glyph: /afii10089

setting alias: /shacyrillic to be the same as glyph: /afii10090

setting alias: /schwacyrillic to be the same as glyph: /afii10846

setting alias: /iishortcyrillic to be the same as glyph: /afii10075

setting alias: /shadelight to be the same as glyph: /ltshade

setting alias: /gjecyrillic to be the same as glyph: /afii10100

setting alias: /yicyrillic to be the same as glyph: /afii10104

setting alias: /kjecyrillic to be the same as glyph: /afii10109

setting alias: /ushortcyrillic to be the same as glyph: /afii10110

setting alias: /blackrightpointingpointer to be the same as glyph: /triagrt

setting alias: /blackrectangle to be the same as glyph: /filledrect

setting alias: /gdot to be the same as glyph: /gdotaccent

setting alias: /Iishortcyrillic to be the same as glyph: /afii10027

setting alias: /ncedilla to be the same as glyph: /ncommaaccent

setting alias: /blackleftpointingpointer to be the same as glyph: /triaglf

setting alias: /blacksquare to be the same as glyph: /filledbox

setting alias: /dbllowline to be the same as glyph: /underscoredbl

setting alias: /Iicyrillic to be the same as glyph: /afii10026

setting alias: /blackdownpointingtriangle to be the same as glyph: /triagdn

setting alias: /gcedilla to be the same as glyph: /gcommaaccent

setting alias: /mars to be the same as glyph: /male

setting alias: /Zecyrillic to be the same as glyph: /afii10025

setting alias: /shadedark to be the same as glyph: /dkshade

setting alias: /dmacron to be the same as glyph: /dcroat

setting alias: /Zhecyrillic to be the same as glyph: /afii10024

setting alias: /Zdot to be the same as glyph: /Zdotaccent

setting alias: /Iocyrillic to be the same as glyph: /afii10023

setting alias: /eighthnotebeamed to be the same as glyph: /musicalnotedbl

setting alias: /Iecyrillic to be the same as glyph: /afii10022

setting alias: /edot to be the same as glyph: /edotaccent

setting alias: /Decyrillic to be the same as glyph: /afii10021

setting alias: /slong to be the same as glyph: /longs

setting alias: /Gecyrillic to be the same as glyph: /afii10020

setting alias: /Vecyrillic to be the same as glyph: /afii10019

setting alias: /quoterightn to be the same as glyph: /napostrophe

setting alias: /whitesmallsquare to be the same as glyph: /H18551

setting alias: /venus to be the same as glyph: /female

setting alias: /Becyrillic to be the same as glyph: /afii10018

setting alias: /whitecircle to be the same as glyph: /circle

setting alias: /blacksmallsquare to be the same as glyph: /H18543

setting alias: /dialytikatonos to be the same as glyph: /dieresistonos

setting alias: /Acyrillic to be the same as glyph: /afii10017

setting alias: /blackcircle to be the same as glyph: /H18533

setting alias: /horizontalbar to be the same as glyph: /afii00208

setting alias: /ostrokeacute to be the same as glyph: /oslashacute

setting alias: /udblacute to be the same as glyph: /uhungarumlaut

setting alias: /Udblacute to be the same as glyph: /Uhungarumlaut

setting alias: /Ncedilla to be the same as glyph: /Ncommaaccent

setting alias: /Odblacute to be the same as glyph: /Ohungarumlaut

setting alias: /rightangle to be the same as glyph: /orthogonal

setting alias: /Rcedilla to be the same as glyph: /Rcommaaccent

setting alias: /whitebullet to be the same as glyph: /openbullet

setting alias: /Idot to be the same as glyph: /Idotaccent

setting alias: /Tcedilla to be the same as glyph: /Tcommaaccent

setting alias: /Edot to be the same as glyph: /Edotaccent

setting alias: /Gjecyrillic to be the same as glyph: /afii10052

setting alias: /careof to be the same as glyph: /afii61248

setting alias: /iicyrillic to be the same as glyph: /afii10074

setting alias: /iucyrillic to be the same as glyph: /afii10096

setting alias: /Djecyrillic to be the same as glyph: /afii10051

setting alias: /blacksmilingface to be the same as glyph: /invsmileface

setting alias: /whitesmilingface to be the same as glyph: /smileface

setting alias: /zecyrillic to be the same as glyph: /afii10073

setting alias: /Gheupturncyrillic to be the same as glyph: /afii10050

setting alias: /euro to be the same as glyph: /Euro

setting alias: /whitecircleinverse to be the same as glyph: /invcircle

setting alias: /zhecyrillic to be the same as glyph: /afii10072

setting alias: /ereversedcyrillic to be the same as glyph: /afii10095

setting alias: /softsigncyrillic to be the same as glyph: /afii10094

setting alias: /IAcyrillic to be the same as glyph: /afii10049

setting alias: /bulletinverse to be the same as glyph: /invbullet

setting alias: /dzhecyrillic to be the same as glyph: /afii10193

setting alias: /iocyrillic to be the same as glyph: /afii10071

setting alias: /thetasymbolgreek to be the same as glyph: /theta1

setting alias: /overscore to be the same as glyph: /macron

setting alias: /IUcyrillic to be the same as glyph: /afii10048

setting alias: /iecyrillic to be the same as glyph: /afii10070

setting alias: /hardsigncyrillic to be the same as glyph: /afii10092

setting alias: /Ereversedcyrillic to be the same as glyph: /afii10047

setting alias: /yericyrillic to be the same as glyph: /afii10093

setting alias: /decyrillic to be the same as glyph: /afii10069

setting alias: /ilde to be the same as glyph: /tilde

setting alias: /nabla to be the same as glyph: /gradient

setting alias: /shchacyrillic to be the same as glyph: /afii10091

setting alias: /afii08941 to be the same as glyph: /lira

setting alias: /Softsigncyrillic to be the same as glyph: /afii10046

setting alias: /rcedilla to be the same as glyph: /rcommaaccent

setting alias: /cdot to be the same as glyph: /cdotaccent

setting alias: /arrowupdownbase to be the same as glyph: /arrowupdnbse

setting alias: /Gdot to be the same as glyph: /Gdotaccent

setting alias: /Yericyrillic to be the same as glyph: /afii10045

setting alias: /compass to be the same as glyph: /sun

setting alias: /notelementof to be the same as glyph: /notelement

setting alias: /Dzhecyrillic to be the same as glyph: /afii10145

setting alias: /Hardsigncyrillic to be the same as glyph: /afii10044

setting alias: /pisymbolgreek to be the same as glyph: /omega1

setting alias: /becyrillic to be the same as glyph: /afii10066

setting alias: /vecyrillic to be the same as glyph: /afii10067

setting alias: /Gcedilla to be the same as glyph: /Gcommaaccent

setting alias: /quoteleftreversed to be the same as glyph: /quotereversed

setting alias: /Shchacyrillic to be the same as glyph: /afii10043

setting alias: /increment to be the same as glyph: /Delta

setting alias: /subsetorequal to be the same as glyph: /reflexsubset

setting alias: /Shacyrillic to be the same as glyph: /afii10042

setting alias: /logicalnotreversed to be the same as glyph: /revlogicalnot

setting alias: /subset to be the same as glyph: /propersubset

setting alias: /zdot to be the same as glyph: /zdotaccent

setting alias: /Checyrillic to be the same as glyph: /afii10041

setting alias: /Tsecyrillic to be the same as glyph: /afii10040

setting alias: /Ushortcyrillic to be the same as glyph: /afii10062

setting alias: /spacehackarabic to be the same as glyph: /space

setting alias: /supersetorequal to be the same as glyph: /reflexsuperset

setting alias: /Khacyrillic to be the same as glyph: /afii10039

setting alias: /approximatelyequal to be the same as glyph: /congruent

setting alias: /superset to be the same as glyph: /propersuperset

setting alias: /Kjecyrillic to be the same as glyph: /afii10061

setting alias: /Efcyrillic to be the same as glyph: /afii10038

setting alias: /acyrillic to be the same as glyph: /afii10065

setting alias: /Tshecyrillic to be the same as glyph: /afii10060

setting alias: /gecyrillic to be the same as glyph: /afii10068

setting alias: /ercyrillic to be the same as glyph: /afii10082

setting alias: /tcedilla to be the same as glyph: /tcommaaccent

setting alias: /Ucyrillic to be the same as glyph: /afii10037

setting alias: /Njecyrillic to be the same as glyph: /afii10059

setting alias: /pecyrillic to be the same as glyph: /afii10081

setting alias: /spadesuitblack to be the same as glyph: /spade

setting alias: /Tecyrillic to be the same as glyph: /afii10036

setting alias: /thereexists to be the same as glyph: /existential

setting alias: /Ljecyrillic to be the same as glyph: /afii10058

setting alias: /dblarrowright to be the same as glyph: /arrowdblright

setting alias: /verticalbar to be the same as glyph: /bar

setting alias: /integralbottom to be the same as glyph: /integralbt

setting alias: /Escyrillic to be the same as glyph: /afii10035

setting alias: /heartsuitblack to be the same as glyph: /heart

setting alias: /forall to be the same as glyph: /universal

setting alias: /Jecyrillic to be the same as glyph: /afii10057

setting alias: /mu1 to be the same as glyph: /mu

setting alias: /Ercyrillic to be the same as glyph: /afii10034

setting alias: /Yicyrillic to be the same as glyph: /afii10056

setting alias: /middot to be the same as glyph: /periodcentered

setting alias: /kcedilla to be the same as glyph: /kcommaaccent

setting alias: /timescircle to be the same as glyph: /circlemultiply

setting alias: /Dslash to be the same as glyph: /Dcroat

setting alias: /arrowleftdbl to be the same as glyph: /arrowdblleft

setting alias: /Pecyrillic to be the same as glyph: /afii10033

setting alias: /integraltop to be the same as glyph: /integraltp

setting alias: /phisymbolgreek to be the same as glyph: /phi1

setting alias: /clubsuitblack to be the same as glyph: /club

setting alias: /Icyrillic to be the same as glyph: /afii10055

setting alias: /dblarrowleft to be the same as glyph: /arrowdblboth

setting alias: /Ocyrillic to be the same as glyph: /afii10032

setting alias: /Cdot to be the same as glyph: /Cdotaccent

setting alias: /shademedium to be the same as glyph: /shade

setting alias: /ldotaccent to be the same as glyph: /ldot

setting alias: /Encyrillic to be the same as glyph: /afii10031

setting alias: /Ecyrillic to be the same as glyph: /afii10053

setting alias: /lsquare to be the same as glyph: /afii61289

setting alias: /lcedilla to be the same as glyph: /lcommaaccent

setting alias: /Emcyrillic to be the same as glyph: /afii10030

FAPIhook ZapfChancery-MediumItalic
Font ZapfChancery-MediumItalic is mapped to FAPI=FreeType
resmp FindResource end

FAPIhook Zapf-Chancery
Font Zapf-Chancery is mapped to FAPI=FreeType
resmp FindResource end
runEPS: Not DSC
runEPS: Not DSC
GS>quit

そのあと、 examples/quicksort.ps ではなく、 examples.ps を実行したところ、魔法陣の画像が指定したファイル(例では output.png) に出力されました。

gswin64c -dDEBUG -dNOSAFER -sDEVICE=pngalpha -sOutputFile=”output.png” mystical.ps examples.ps

examples.ps と examples/quicksort.ps の内容を比較すると、 examples.ps には、 showpage や mystical.ps で定義されている executable_name の文字列が使われていました。

showpage は、それまでに描画した内容で、1ページ分の記述が終了したことを表します。
これによって、今まで描画した内容が1ページの画像として確定します。

様々な図形やテキストを記述した後、 showpage operator を書くと、1ページ分の記述が終了します。

そのことから、おそらく、 examples/quicksort.ps ではなく examples.ps の方が、mystical.ps の機能を使った画像生成に適したスクリプトだと思われるので、example.ps を例に mystical.ps による画像変換を行うことにしました。

シンボリックリンクに対応した git clone で取得しないと機能しない

mystical_ps の直下に配置する dmmlib には、シンボリックリンクが含まれています。

Git for Windows のデフォルトの設定では、シンボリックリンクはサポートされず、シンボリックリンクを clone で取得すると、 lines/lines.ps のような相対パスが書かれたテキストファイルになってしまいます。

以下はシンボリックリンクに対応しない、デフォルトの設定で git clone コマンドで dmmlib を取得した際の、実行結果です。

ハイライトされている 23 行目で gswin64c で mystical.ps を実行すると、ハイライトされている 28 行目で Error: /undefined in lines と表示されてエラーが発生しています。

Microsoft Windows [Version 10.0.19045.5854]
(c) Microsoft Corporation. All rights reserved.

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>git clone https://github.com/denismm/dmmlib.git
Cloning into 'dmmlib'...
remote: Enumerating objects: 417, done.
remote: Counting objects: 100% (210/210), done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 417 (delta 122), reused 166 (delta 80), pack-reused 207 (from 1)
Receiving objects: 100% (417/417), 859.91 KiB | 7.05 MiB/s, done.
Resolving deltas: 100% (218/218), done.

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>cd dmmlib

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main\dmmlib>git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main\dmmlib>cd ..

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png mystical.ps examples.ps
GPL Ghostscript 10.05.1 (2025-04-29)
Copyright (C) 2025 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /undefined in lines
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1949   1   3   %oparray_pop   1948   1   3   %oparray_pop   1933   1   3   %oparray_pop   1803   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1949   1   3   %oparray_pop   1948   1   3   %oparray_pop   1933   1   3   %oparray_pop   1803   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:756/1123(ro)(G)--   --dict:0/20(G)--   --dict:187/200(L)--
Current allocation mode is local
Current file position is 5
GPL Ghostscript 10.05.1: Unrecoverable error, exit code 1

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>

これは、本来シンボリックリンクである lines.ps が、 lines/lines.ps というリンク先の相対パスが書かれたテキストファイルに変わっていたために、 lines が読み込まれなかったために発生したエラーです。

Mystical シンボリックリンクに対応しない git clone ではそれはテキストファイルに変わってしまいます。

シンボリックリンクに対応した git clone を行うと、 .symlink が作られ、シンボリックリンクとして機能し、先ほどのように Error: /undefined in lines というエラーは発生しません。

Mystical シンボリックリンクに対応した git clone では.symlink として作成されます。

シンボリックリンクに対応した git clone で取得しないと機能しない問題とその対処例については、以下の記事を参照してください。

 https://compota-soft.work/wp1/wp-admin/post.php?post=52144&action=edit

 https://compota-soft.work/wp1/wp-admin/post.php?post=52290&action=edit

-dNOSAFER の必要性

-dNOSAFER を指定しないと Error: /invalidfileaccess in –run– というエラーメッセージが表示されます。

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>gswin64c mystical.ps examples.ps
GPL Ghostscript 10.05.1 (2025-04-29)
Copyright (C) 2025 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /invalidfileaccess in --run--
Operand stack:
   (dmmlib/base.ps)   (r)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   run   --nostringval--   2   %stopped_push   --nostringval--   run   run   false   1   %stopped_push   1949   1   3   %oparray_pop   1948   1   3   %oparray_pop   1933   1   3   %oparray_pop   1803   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   run   --nostringval--   2   %stopped_push   --nostringval--   1949   1   3   %oparray_pop   run
Dictionary stack:
   --dict:746/1123(ro)(G)--   --dict:0/20(G)--   --dict:85/200(L)--
Current allocation mode is local
Last OS error: Permission denied
Current file position is 24
GPL Ghostscript 10.05.1: Unrecoverable error, exit code 1

-dNOSAFER オプションは、 GhostScrpt 9.50 以降にデフォルトになったファイルアクセス制御を抑制して、Error: /invalidfileaccess in –run– などのエラー回避できます。

I use gv, which requires X and is only available on homebrew through a nonstandard cask, because I like its functionality much more than gsview, but in any case it’s useful to be able to interpret ps without generating a pdf. You will need to add the -dNOSAFER option to “gs options” in whatever tool you use.

私は gv を使用します。これは X を必要とし、非標準カスクを介して homebrew でのみ利用可能です。これは、その機能が gsview よりもはるかに気に入っているためです。しかし、いずれにせよ、pdf を生成せずに ps を解釈できるのは便利です。  どのツールを使用する場合でも、「gs options」に「-dNOSAFER」オプションを追加する必要があります。
mystical_ps/INSTALL.md at main · denismm/mystical_ps

Ghostscript 9.50 以降ではデフォルトでファイルアクセス制御が有効となったため,-dNOSAFER オプションが必要となりました. オプションを付けないと,PBM への変換処理に失敗して警告ダイアログボックスが表示されます.

USBメモリ活用講座【dviout for Windowsポータブル化】

-sDEVICE, -sOutputFile で画像をファイル出力

-sDEVICE オプションで生成する画像のフォーマットを、 -sOutputFile オプションで出力先のファイルパスを指定しないと、Ghostscript Image ウィンドウに表示されるだけで、ファイルに保存されません。

Mystical example.ps の魔法陣の画像が showpage によって GhostScript Image ウィンドウに表示されました。

次に、 –sDEVICE に画像形式、 -sOutputFile にファイル出力先を指定したオプションを追加したコマンドを実行します。
examples.ps の内部で mystical.ps も実行されています。

gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png examples.ps

上記のコマンドを入力して showpage のタイミングでメッセージに従って Enter キーを押してから GS> のモードを quit で抜けます。

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>gswin64c -dNOSAFER -sDEVICE=png16m -sOutputFile=output.png examples.ps
GPL Ghostscript 10.05.1 (2025-04-29)
Copyright (C) 2025 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Querying operating system for font files...
Can't find (or can't open) font file %rom%Resource/Font/%rom%Resource.
Can't find (or can't open) font file Zapf-Chancery.
Didn't find this font on the system!
Substituting font ZapfChancery-MediumItalic for Zapf-Chancery.
Loading Z003-MediumItalic font from %rom%Resource/Font/Z003-MediumItalic... 3484824 2160629 3177240 1882847 1 done.
>>showpage, press <return> to continue<<

GS>quit

G:\Dev\Mistical\mystical_ps-main\mystical_ps-main>

フォルダを見ると、output.png ファイルが出力され、画像は先ほど Ghostscript Image ウィンドウで確認したものと同じでした。

Mystical example.ps の魔法陣の画像が -sDEVICE, -sOutputFile で指定した形式でファイルに保存されました。

まとめ

今回は、前回の補足として、mystical.ps を使用して PostScript のプログラムを魔法陣の画像に変換する際に用いた -dNOSAFER, -sDEVICE, -sOutputFile オプションを用いた理由や、画像に変換するサンプルとして同梱の examples.ps が適していることなどについて、調べてわかったことを前回の記事の補足として紹介しました。

参照サイト Thank You!

記事一覧 → Compota-Soft-Press

コメント

Ads Blocker Image Powered by Code Help Pro

お願い - Ads Blocker Detected

このサイトは広告を掲載して運営しています。

ポップアップを閉じて閲覧できますが、よろしければ

このサイト内の広告を非表示にする拡張機能をオフにしていただけませんか?

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

タイトルとURLをコピーしました