{"id":13681927,"url":"https://github.com/livesense-inc/fanlin","last_synced_at":"2025-07-01T00:05:28.413Z","repository":{"id":57503347,"uuid":"60678769","full_name":"livesense-inc/fanlin","owner":"livesense-inc","description":"Fast ANd LIghtweight Natural image processor","archived":false,"fork":false,"pushed_at":"2025-05-14T01:15:01.000Z","size":2805,"stargazers_count":30,"open_issues_count":3,"forks_count":7,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-14T02:55:38.221Z","etag":null,"topics":["golang","image-processing","linux","neural-network"],"latest_commit_sha":null,"homepage":"https://deepwiki.com/livesense-inc/fanlin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livesense-inc.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-06-08T07:43:19.000Z","updated_at":"2025-05-14T01:13:17.000Z","dependencies_parsed_at":"2023-12-18T07:23:19.703Z","dependency_job_id":"a5b246b7-5606-455d-8f3a-ede46f18040f","html_url":"https://github.com/livesense-inc/fanlin","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/livesense-inc/fanlin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livesense-inc%2Ffanlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livesense-inc%2Ffanlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livesense-inc%2Ffanlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livesense-inc%2Ffanlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livesense-inc","download_url":"https://codeload.github.com/livesense-inc/fanlin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livesense-inc%2Ffanlin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870871,"owners_count":23377311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","image-processing","linux","neural-network"],"created_at":"2024-08-02T13:01:37.826Z","updated_at":"2025-07-01T00:05:28.339Z","avatar_url":"https://github.com/livesense-inc.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# fanlin\n\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/livesense-inc/fanlin)\n![Test](https://github.com/livesense-inc/fanlin/actions/workflows/test.yml/badge.svg?branch=master)\n![Release](https://github.com/livesense-inc/fanlin/actions/workflows/release.yaml/badge.svg)\n\n[English](README.md) | 日本語\n\n## 概要\nfanlinはGo言語で作られた軽量画像プロキシです.\nAmazon S3と外部HTTPサーバー上の画像をリアルタイムで加工することができます.\n\n## 環境\n### OS\n* Linux (x86 and amd64)\n* macOS\n\n### Go Versions\n* `go.mod` ファイル参照\n\n## 対応画像フォーマット\n* JPEG\n* PNG\n* GIF\n* WebP\n* AVIF (エンコードのみ)\n\n## macOS の環境構築\n## master pushの悲劇を防ぐために\n[ここを参考に設定すること](http://ganmacs.hatenablog.com/entry/2014/06/18/224132)\n\n## 依存ライブラリ\nAVIFフォーマットのエンコードのためにlibaomが必要です。事前にインストールしておいてください。\n\n```\n$ sudo apt install libaom-dev\n```\n\nまた、ICCプロファイルを利用してCMYKをRGBに変換するための以下も必要です。\n\n```\n$ sudo apt install liblcms2-dev\n```\n\n## Linux用にクロスコンパイルする\n```\n$ GOOS=linux GOARCH=amd64 go build github.com/livesense-inc/fanlin/cmd/fanlin\n```\n\n## サーバーに配布するもの\nビルドして作った実行ファイル  \n設定ファイル\n\n## API\ngetパラメータに値を渡して操作する  \n`w`画像の横幅  \n`h`画像の縦幅  \n色を指定しない時`w`と`h`を指定した時は小さい方に合わせて縮尺を変更する  \nこの時アスペクト比は維持する  \nまた一方が`0`の時は`0`ではない値を基準に縮尺を変更する  \n`w`及び`h`が`0`であるときは元のサイズで表示する  \nあまりにも大きいサイズが指定された時は設定ファイルにかかれている上限の大きさで拡大する  \n`rgb`で色を指定した場合`w`と`h`で指定された大きさの画像を生成する  \nこの時画像のアスペクト比が違うときは隙間を指定した色で塗りつぶす\n`quality`で`0`から`100`までの数値を指定した場合その数値にクオリティを設定した画像を生成する\nそれ以外の数値が指定された場合は`jpeg.DefaultQuality`の値(`75`)が指定される\n`crop`で`true`が指定された場合`w`と`h`で指定した比に合わせて、画像中央を基準としてはみ出した部分クロッピングして画像を生成する\n例:  \n```\nhttp://localhost:8080/path/to/image/?h=400\u0026w=400\u0026rgb=100,100,100\u0026quality=80\u0026crop=true\n```\n\n## testing\n```\n$ go test -cover ./...\n```\n\n## 設定項目に関して\nだいたいこんな感じでかけます\n```json\n{\n    \"port\": 8080,\n    \"max_width\": 1000,\n    \"max_height\": 1000,\n    \"404_img_path\": \"/path/to/404/image\",\n    \"access_log_path\": \"/path/to/access/log\",\n    \"error_log_path\": \"/path/to/error/log\",\n    \"use_server_timing\": true,\n    \"providers\": [\n        {\n            \"/alias/0\" : {\n                \"type\" : \"web\",\n                \"src\" : \"http://aaa.com/bbb\",\n                \"priority\" : 10\n            }\n        },\n        {\n            \"/alias/1\" : {\n                \"type\" : \"web\",\n                \"src\" : \"https://ccc.com\",\n                \"priority\" : 20\n            }\n        },\n        {\n            \"/alias/3\" : {\n                \"type\" : \"s3\",\n                \"src\" : \"s3://bucket/path\",\n                \"region\" : \"ap-northeast-1\",\n                \"priority\" : 30\n            }\n        }\n    ]\n}\n```\n\n## ログの出力先を制御する\n設定項目の`access_log_path`/`error_log_path`/`debug_log_path`にパスを指定することで、それぞれのログをファイルに出力できます。\n標準出力にログを出力したい場合は、`/dev/stdout`を指定してください。\n\n## WebPフォーマットの利用方法と制限事項\nfanlinへのリクエストに `webp=true` getパラメータを付与することで、WebPフォーマットの画像を返すことが出来ます.\n\n例:\n\n- JPG画像のURL:\n  - http://localhost:8080/abc.jpg?h=400\u0026w=400\u0026quality=80\n- WebPに変換した画像のURL:\n  - http://localhost:8080/abc.jpg?h=400\u0026w=400\u0026quality=80\u0026webp=true\n\nまた、以下の条件の場合は、Lossless WebPフォーマットで変換します.\n\n- getパラメータにて `quality=100` を指定かつ元画像のフォーマットが PNG / GIF / WebP のいずれか\n\n### 制限事項\n\n- アニメーションには対応していません\n\n\n## Server-Timingのサポートに関して\n\n設定ファイルのグローバル設定値に `\"use_server_timing\": true` を入れることで[Server-Timing](https://www.w3.org/TR/server-timing/)が出力されます.\nServer-Timingの出力によって、システムの内部構成やパフォーマンスがエンドユーザーに見えてしまう可能性があります.利用に際してはご注意ください.\n\n現在の出力項目は以下:\n\n- f_load: ソース画像のロード時間\n- f_decode: ソース画像のデコードと加工時間\n- f_encode: 最終出力フォーマットへのエンコード時間\n\n## モックサーバーを利用してAmazon S3バックエンドの動作確認を手元でする\n`providers` directive にて `use_mock` 属性を `true` に指定すると fanlin はローカルのモックサーバーを参照するように動作します。\n\n```json\n{\n    \"port\": 3000,\n    \"max_width\": 2000,\n    \"max_height\": 1000,\n    \"404_img_path\": \"img/404.png\",\n    \"access_log_path\": \"/dev/stdout\",\n    \"error_log_path\": \"/dev/stderr\",\n    \"max_clients\": 50,\n    \"providers\": [\n        {\n            \"/foo\": {\n                \"type\": \"s3\",\n                \"src\": \"s3://local-test/images\",\n                \"region\": \"ap-northeast-1\",\n                \"norm_form\": \"nfd\",\n                \"use_mock\": true\n            }\n        },\n        {\n            \"/bar\": {\n                \"type\": \"web\",\n                \"src\": \"http://localhost:3000/foo\"\n            }\n        },\n        {\n            \"/baz\": {\n                \"type\": \"local\",\n                \"src\": \"img\"\n            }\n        }\n\n    ]\n}\n```\n\nfanlin 起動前に Docker compose でモックサーバーを起動しておいてください。\n\n```\n$ docker compose up\n$ make create-s3-bucket\n$ make copy-object SRC=img/Lenna.jpg DEST=images/Lenna.jpg\n$ make run\n```\n\nこれでローカルで動作確認ができます。\n\n```\n$ curl -I 'http://localhost:3000/foo/Lenna.jpg?w=300\u0026h=200\u0026rgb=64,64,64'\n$ curl -I 'http://localhost:3000/bar/Lenna.jpg?w=300\u0026h=200\u0026rgb=64,64,64'\n$ curl -I 'http://localhost:3000/baz/Lenna.jpg?w=300\u0026h=200\u0026rgb=64,64,64'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivesense-inc%2Ffanlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivesense-inc%2Ffanlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivesense-inc%2Ffanlin/lists"}