#author("2021-11-16T00:58:54+00:00","default:hotate","hotate") #author("2023-01-09T03:28:20+00:00","default:hotate","hotate") #contents &tag(画像処理); * フォーマット [#xc84a0d1] - [[SVG入門 - とほほのWWW入門>https://www.tohoho-web.com/ex/svg.html]] Web でよく使用される SVG 画像フォーマットについて説明します。 * ツール [#x93dfafc] ** ImageMagick [#kf8e063d] - [[画像処理ツール ImageMagick の便利なコマンド逆引きまとめ|てくめも@ecoop.net>https://www.ecoop.net/memo/archives/imagemagick_reverse_lookup.html]] SVGからPNG(JPEG,GIF)へ変換する。 convert input.svg -resize 1600x1600 output.png - [[convertコマンドの使い方: UNIX/Linuxの部屋>http://x68000.q-e-d.net/~68user/unix/pickup?convert#prgmemo-convert-trim]] -- コメント:ImageMagick 6.9.11-53にて確認したところ、クロップ領域が考慮されず大きな画像として出力されたので、実用性は今ひとつ。 (2021/04/25) ** [[Python]] [#z32b24b4] + [[Pythonでsvgファイルをpng/icoに変換する - Qiita>https://qiita.com/tommarute/items/58a38e340c4040976e40]] svg -> png の変換は cairosvg ってやつを使えばできるらしい。 -- コメント:[[Python3]].9, [[BigSur]]にて正常に変換出来た。(2021/04/25) -- コメント:[[Windows]]では別途Cコンパイラのインストールが必要な為、未検証。(2021/04/26) --- [[Documentation - CairoSVG>https://cairosvg.org/documentation/]] - on Windows, you’ll have to install Visual C++ compiler for Python and Cairo; -- コメント:[[Windows]]でCコンパイラによるビルドとインストールは成功したが、別途ライブラリの追加が必要。未検証。(2021/11/16) --- [[python - get cairosvg working in windows - Stack Overflow>https://stackoverflow.com/questions/46265677/get-cairosvg-working-in-windows]] get a copy of libcairo-2.dll + [[svglib · PyPI>https://pypi.org/project/svglib/]] Svglib is a pure-Python library for reading SVG files and converting them (to a reasonable degree) to other formats using the ReportLab Open Source toolkit. -- コメント:[[Windows]]で試したところ"Can't handle color: url(#...)"のエラーが出てpngへの変換に失敗した。(2021/04/26) ** [[macOS]] [#l01ae35f] - [[Macで有料アプリがやってることをコマンドで実行する - Qiita>https://qiita.com/Ping/items/88331d638df5fb6be06d#svg%E3%81%AE%E7%A2%BA%E8%AA%8D]] 注意点としては、大きい辺を元に正方形にするので、加工は別にする必要があるでしょう。 -- コメント:上記の記載通りの結果なので、実用性は今ひとつ。(2021/04/26) * 関連 [#jada9b51] #related #taglist(tag=画像処理)