Git Product home page Git Product logo

ogpgen's Introduction

tn

インストールとビルド

必要環境

  • Git
  • Go (version 1.19.3 で動作確認済)
git clone https://github.com/k1350/ogpgen.git
cd ogpgen
go build -o ogpgen ./cmd/ogpgen

使い方

最低限の引数指定時

./ogpgen -text="OGP 画像生成ツール" -bpath="/your_template/template.jpg" -fpath="/your_font/03SmartFontUI.ttf"

引数全指定時

./ogpgen -text="OGP 画像生成ツール" -bpath="/your_template/template.jpg" -fpath="/your_font/03SmartFontUI.ttf" -fsize=90 -fcolor="#A2Ad0580" -tmargin=75 -smargin=90 -lspace=10 -o="/out_dir/output.jpg"

引数の説明

  • text: 【必須】描画したい文字列。
  • bpath: 【必須】背景に使用する画像ファイルのパス。JPEG でなければならない。
  • fpath: 【必須】使用するフォントファイルのパス。TrueType フォントでなければならない。
  • fsize: フォントサイズ。0 より大きい数でなければならない。小数点以下も指定できる。未指定の場合は 100.0 になる。
  • fcolor: フォント色を6桁または8桁(透明度指定あり)のカラーコードで指定する。未指定の場合は #000000 になる。
  • tmargin: 上部マージン。文字が描画される位置が、正の値を指定すると下側に、負の値を指定すると上側にずれる。未指定の場合は 0 になる。
  • smargin: 左右マージン。大きい値を指定するほど文字が**に寄る。未指定の場合は 0 になる。
  • lspace: 行間。正の値を指定すると行間が広がり、負の値を指定すると詰まる。未指定の場合は 0 になる。
  • o: 出力ファイル名。未指定の場合は out.jpg になる。

開発

テスト

このファイルがあるディレクトリの一つ上の階層に ogpgen_files というディレクトリを作り、下記の構成でファイルを置いておかないと一部テストが動作しない。

ogpgen_files
|
|-fonts
| |-03SmartFontUI.ttf
|
|-templates
  |-template.jpg

03SmartFontUI.ttf は TrueType フォントなら何でもいい。

template.jpg は OGP 画像のベースになる適当な jpg ファイル。

ogpgen's People

Contributors

k1350 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.