Movatterモバイル変換


[0]ホーム

URL:


Multipath

MultiPath#

Starting from version0.9.9, we’re supporting multipath, thanks to contribution by@bugfest ❤️.

If you’d like to use multiple path for serving different images, you can use the newconfig.json format. You can specify additional paths mappings underIMG_MAP dict.

IMG_MAP’s keys are URIs or Hosts names will be translated to their corresponding mapped value. It works in two different modes:

Keys not matching this format will be ignored

The values can be:

Example:

{"HOST":"0.0.0.0","PORT":"3333","QUALITY":"80","IMG_PATH":"./pics","EXHAUST_PATH":"./exhaust","IMG_MAP": {"/2":"./pics2","/3":"./pics3","http://www.example.com":"https://docs.webp.sh"  },"ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif","svg","heic","nef"],"CONVERT_TYPES": ["webp"],"STRIP_METADATA":true,"CACHE_TTL":259200,"ENABLE_EXTRA_PARAMS":false}

For example, you have some images under./pics,./pics2 and./pics3, as below:

Then you can access them via:

For the last example to work you need to pass theHost header as part of the request. If you usecurl you can test it with the commandcurl -H 'Host: www.example.com' http://localhost:3333/favicon.png

Note when using a remote backend#

If you’re using a remote backend, like"http://www.example.com": "https://docs.webp.sh" in the example above, you need to make sure the remote backend is reachable by the local instance and will satisfy the following requirements:

Headers#

We useEtag header from backend to fetch and refresh/rebuild cache, so it’s a need that your backend’s response will contain aEtag header.

We useHEAD request to get remote image info(to see if image still exist and whether it has changed), so your backend needs to supportHEAD request, after first successfullyHEAD request, it will be cached forCACHE_TTLminutes, during that period, we will not sendHEAD request again and use local cache for rendering.

Supported(tested) backends:

Note onIMG_MAP#

If you have multiple paths sharing the same prefix, for example:

Please be sure the longer prefix item is above the shorter one, for the example above, theIMG_MAP section should be defined as follows:

"IMG_MAP": {"/image1":"./some-path","/image":"./some-other-path","/im":"https://some-image.webp.sh"},

[8]ページ先頭

©2009-2025 Movatter.jp