{"id":13413207,"url":"https://github.com/thoas/picfit","last_synced_at":"2025-05-14T04:09:02.217Z","repository":{"id":24249264,"uuid":"27642603","full_name":"thoas/picfit","owner":"thoas","description":"An image resizing server written in Go","archived":false,"fork":false,"pushed_at":"2025-04-19T09:40:24.000Z","size":115680,"stargazers_count":2204,"open_issues_count":12,"forks_count":184,"subscribers_count":54,"default_branch":"main","last_synced_at":"2025-04-19T15:38:59.344Z","etag":null,"topics":["golang","image","server"],"latest_commit_sha":null,"homepage":"http://bit.ly/1E7rSoi","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/thoas.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-06T17:30:45.000Z","updated_at":"2025-04-19T09:40:26.000Z","dependencies_parsed_at":"2023-11-07T13:33:11.066Z","dependency_job_id":"8c0e2d97-5231-47a5-82f5-0a9227d67f79","html_url":"https://github.com/thoas/picfit","commit_stats":{"total_commits":525,"total_committers":28,"mean_commits":18.75,"dds":"0.24571428571428566","last_synced_commit":"952eb78d3f45571677d3049c1383c43b316f84ee"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoas%2Fpicfit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoas%2Fpicfit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoas%2Fpicfit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoas%2Fpicfit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoas","download_url":"https://codeload.github.com/thoas/picfit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254070012,"owners_count":22009558,"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","server"],"created_at":"2024-07-30T20:01:35.160Z","updated_at":"2025-05-14T04:08:57.200Z","avatar_url":"https://github.com/thoas.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Images","Image Processing","Open source library","Programming Languages","图像","Images 图像处理","图片","圖象","Relational Databases","\u003cspan id=\"图片-images\"\u003e图片 Images\u003c/span\u003e"],"sub_categories":["图形处理","Search and Analytic Databases","Snippets Manager","Graphics Processing","Advanced Console UIs","Go","高级控制台界面","交流","SQL 查询语句构建库","检索及分析资料库","高級控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"picfit\n======\n\n.. image:: https://d262ilb51hltx0.cloudfront.net/max/800/1*oR04S6Ie7s1JctwjsDsN0w.png\n\npicfit is a reusable Go server to manipulate images (resize, thumbnail, etc.).\n\nIt will act as a proxy on your storage engine and will be\nserved ideally behind an HTTP cache system like varnish_.\n\nIt supports multiple `storage backends \u003chttps://github.com/ulule/gostorages\u003e`_\nand multiple `key/value stores \u003chttps://github.com/ulule/gokvstores\u003e`_.\n\nInstallation\n============\n\nBuild it\n--------\n\n1. Make sure you have a Go language compiler and git installed.\n2. Make sure you have the following go system dependencies in your $PATH: bzr, svn, hg, git\n3. Ensure your GOPATH_ is properly set.\n4. Download it:\n\n::\n\n    git clone https://github.com/thoas/picfit.git\n\n4. Run ``make build``\n\nYou have now a binary version of picfit in the ``bin`` directory which\nfits perfectly with your architecture.\n\npicfit has also a Docker integration to built a unix binary without having to install it\n\n::\n\n    make docker-build\n\nDebian and Ubuntu\n-----------------\n\nWe will provide Debian package when we will be completely stable ;)\n\nConfiguration\n=============\n\nConfiguration should be stored in a readable file and in JSON format.\n\nThe location of the configuration is specified by --config or the PICFIT_CONFIG_PATH environment variable.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"kvstore\": {\n        \"type\": \"[KVSTORE]\"\n      },\n      \"storage\": {\n        \"src\": {\n          \"type\": \"[STORAGE]\"\n        }\n      }\n    }\n\n``[KVSTORE]`` can be:\n\n- **redis** - generated keys stored in Redis_, see `below \u003c#store-images-on-amazon-s3-keys-in-redis-and-shard-filename\u003e`_ how you can customize connection parameters\n- **cache** - generated keys stored in an in-memory cache\n- **redis-cluster** - generated keys stored in `Redis cluster \u003chttps://redis.io/topics/cluster-tutorial\u003e`_\n- **redis-roundrobin** - generated keys stored in Redis_, using multiple replicas to read keys, picfit will automatically detects a write error and round robin to the primary\n\n``[STORAGE]`` can be:\n\n- **fs** - generated images stored in your File system\n- **http+fs** - generated images stored in your File system and loaded using HTTP protocol\n- **s3** - generated images stored in Amazon S3\n- **dos3** - generated images stored in DigitalOcean S3\n- **gcs** - generated images stored in Google Cloud Storage\n- **http+s3** - generated images stored in Amazon S3 and loaded using HTTP protocol\n- **http+dos3** - generated images stored in DigitalOcean S3 and loaded using HTTP protocol\n\nBasic\n-----\n\n* no key/value store\n* no image storage\n* images are given in absolute url\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"port\": 3001\n    }\n\nImages are generated on the fly at each request.\n\nStore images on file system and keys in an in-memory cache\n----------------------------------------------------------\n\n* key/value in-memory store\n* file system storage\n\nAn image is generated from your source storage (``src``) and uploaded\nasynchronously to this storage.\n\nA unique key is generated and stored in a in-memory key/value store to process\na request only once.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"port\": 3001,\n      \"storage\": {\n        \"src\": {\n          \"type\": \"fs\",\n          \"location\": \"/path/to/directory/\"\n        }\n      },\n      \"kvstore\": {\n        \"type\": \"cache\"\n      }\n    }\n\nStore images on DigitalOcean S3\n-----------------------------------------------------------\n\nIt's mostly the same as Amazon S3 storage, the difference are accepted regions\nSo, regions can be:\n\n- nyc1\n- nyc2\n- nyc3\n- ams2\n- ams3\n- sfo1\n- sfo2\n- sgp1\n- lon1\n- fra1\n- tor1\n- blr1\n\nStore images on Amazon S3, keys in Redis and shard filename\n-----------------------------------------------------------\n\n* key/value store provided by Redis\n* Amazon S3 storage\n* shard filename\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"kvstore\": {\n        \"type\": \"redis\",\n        \"redis\": {\n          \"host\": \"127.0.0.1\",\n          \"port\": 6379,\n          \"password\": \"\",\n          \"db\": 0\n        }\n      },\n      \"port\": 3001,\n      \"storage\": {\n        \"src\": {\n          \"type\": \"s3\",\n          \"access_key_id\": \"[ACCESS_KEY_ID]\",\n          \"secret_access_key\": \"[SECRET_ACCESS_KEY]\",\n          \"bucket_name\": \"[BUCKET_NAME]\",\n          \"acl\": \"[ACL]\",\n          \"region\": \"[REGION_NAME]\",\n          \"location\": \"path/to/directory\",\n          \"endpoint\": \"[protocol://service-code.region-code.amazonaws.com]\"\n        }\n      },\n      \"shard\": {\n        \"width\": 1,\n        \"depth\": 2,\n        \"restonly\": true\n      }\n    }\n\nKeys will be stored on Redis_, (you better need to setup persistence_).\n\nImage files will be loaded and stored on Amazon S3 at the location ``path/to/directory``\nin the bucket ``[BUCKET_NAME]``.\n\n``[ACL]`` can be:\n\n- private\n- public-read\n- public-read-write\n- authenticated-read\n- bucket-owner-read\n- bucket-owner-full-control\n\n``[REGION_NAME]`` can be:\n\n- us-gov-west-1\n- us-east-1\n- us-west-1\n- us-west-2\n- eu-west-1\n- eu-central-1\n- ap-southeast-1\n- ap-southeast-2\n- ap-northeast-1\n- sa-east-1\n- cn-north-1\n\n**Filename** will be sharded:\n\n- ``depth`` - 2 directories\n- ``width`` - 1 letter for each directory\n- ``restonly`` - true, filename won't contain characters in sharding path\n\nExample:\n\n``06102586671300cd02ae90f1faa16897.png`` will become ``0/6/102586671300cd02ae90f1faa16897.jpg``\n\nwith restonly=false it would become ``0/6/06102586671300cd02ae90f1faa16897.jpg``\n\nIt would be useful if you are using the file system storage backend.\n\nLoad images from file system and store them in Amazon S3, keys on Redis cluster\n-------------------------------------------------------------------------------\n\n* key/value store provided by Redis cluster\n* File system to load images\n* Amazon S3 storage to process images\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"kvstore\": {\n        \"type\": \"redis-cluster\",\n        \"redis\": {\n          \"addrs\": [\n            \"127.0.0.1:6379\"\n          ],\n          \"password\": \"\",\n        }\n      },\n      \"port\": 3001,\n      \"storage\": {\n        \"src\": {\n          \"type\": \"fs\",\n          \"location\": \"path/to/directory\"\n        },\n        \"dst\": {\n          \"type\": \"s3\",\n          \"access_key_id\": \"[ACCESS_KEY_ID]\",\n          \"secret_access_key\": \"[SECRET_ACCESS_KEY]\",\n          \"bucket_name\": \"[BUCKET_NAME]\",\n          \"acl\": \"[ACL]\",\n          \"region\": \"[REGION_NAME]\",\n          \"location\": \"path/to/directory\",\n          \"endpoint\": \"[protocol://service-code.region-code.amazonaws.com]\"\n        }\n      }\n    }\n\nYou will be able to load and store your images from different storages backend.\n\nIn this example, images will be loaded from the file system storage\nand generated to the Amazon S3 storage.\n\nKeys stored in Redis with multiple replicas\n-------------------------------------------\n\n* key/value store provided by Redis with replicas\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"kvstore\": {\n        \"type\": \"redis-roundrobin\",\n        \"redis-roundrobin\": {\n          \"addrs\": [\n            \"redis://127.0.0.1:6379?db=0\",\n            \"redis://127.0.0.1:6380?db=0\"\n          ]\n        }\n      },\n      \"port\": 3001\n    }\n\nLoad images from storage backend base url, store them in Amazon S3, keys prefixed on Redis\n------------------------------------------------------------------------------------------\n\n* key/value store provided by Redis\n* File system to load images using HTTP method\n* Amazon S3 storage to process images\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"kvstore\": {\n        \"type\": \"redis\",\n        \"redis\": {\n          \"host\": \"127.0.0.1\",\n          \"port\": 6379,\n          \"password\": \"\",\n          \"db\": 0\n        },\n        \"prefix\": \"dummy:\"\n      },\n      \"port\": 3001,\n      \"storage\": {\n        \"src\": {\n          \"type\": \"http+fs\",\n          \"base_url\": \"http://media.example.com\",\n          \"location\": \"path/to/directory\"\n        },\n        \"dst\": {\n          \"type\": \"s3\",\n          \"access_key_id\": \"[ACCESS_KEY_ID]\",\n          \"secret_access_key\": \"[SECRET_ACCESS_KEY]\",\n          \"bucket_name\": \"[BUCKET_NAME]\",\n          \"acl\": \"[ACL]\",\n          \"region\": \"[REGION_NAME]\",\n          \"location\": \"path/to/directory\"\n        }\n      }\n    }\n\nIn this example, images will be loaded from the file system storage\nusing HTTP with ``base_url`` option and generated to the Amazon S3 storage.\n\nKeys will be stored on Redis_ using the prefix ``dummy:``.\n\nRunning\n=======\n\nTo run the application, issue the following command:\n\n::\n\n    $ picfit -c config.json\n\nBy default, this will run the application on port 3001 and\ncan be accessed by visiting:\n\n::\n\n    http://localhost:3001\n\nThe port number can be configured with ``port`` option in your config file.\n\nTo see a list of all available options, run:\n\n::\n\n    $ picfit --help\n\nUsage\n=====\n\nGeneral parameters\n------------------\n\nParameters to call the picfit service are:\n\n.. code-block:: html\n\n    \u003cimg src=\"http://localhost:3001/{method}?url={url}\u0026path={path}\u0026w={width}\u0026h={height}\u0026upscale={upscale}\u0026sig={sig}\u0026op={operation}\u0026fmt={format}\u0026q={quality}\u0026deg={degree}\u0026pos={position}\u0026filter={filter}\"\n\n- **path** - The filepath to load the image using your source storage\n- **operation** - The operation to perform, see Operations_\n- **sig** - The signature key which is the representation of your query string and your secret key, see Security_\n- **method** - The method to perform, see Methods_\n- **url** - The url of the image to generate (not required if ``path`` provided)\n- **width** - The desired width of the image, if ``0`` is provided the service will calculate the ratio with ``height``\n- **height** - The desired height of the image, if ``0`` is provided the service will calculate the ratio with ``width``\n- **upscale** - If your image is smaller than your desired dimensions, the service will upscale it by default to fit your dimensions, you can disable this behavior by providing ``0``\n- **format** - The output format to save the image, by default the format will be the source format (a ``GIF`` image source will be saved as ``GIF``),  see Formats_\n- **quality** - The quality to save the image, by default the quality will be the highest possible, it will be only applied on ``JPEG`` format\n- **degree** - The degree (``90``, ``180``, ``270``) to rotate the image\n- **position** - The position to flip the image\n- **filter** - The filter for the effect operation (``blur``)\n\nTo use this service, include the service url as replacement\nfor your images, for example:\n\n.. code-block:: html\n\n    \u003cimg src=\"https://www.google.fr/images/srpr/logo11w.png\" /\u003e\n\nwill become:\n\n.. code-block:: html\n\n    \u003cimg src=\"http://localhost:3001/display?url=https%3A%2F%2Fwww.google.fr%2Fimages%2Fsrpr%2Flogo11w.png\u0026w=100\u0026h=100\u0026op=resize\u0026upscale=0\"\n\nThis will retrieve the image used in the ``url`` parameter and resize it\nto 100x100.\n\nUsing source storage\n--------------------\n\nIf an image is stored in your source storage at the location ``path/to/file.png``,\nthen you can call the service to load this file:\n\n.. code-block:: html\n\n    \u003cimg src=\"http://localhost:3001/display?w=100\u0026h=100\u0026path=path/to/file.png\u0026op=resize\"\n\n    or\n\n    \u003cimg src=\"http://localhost:3001/display/resize/100x100/path/to/file.png\"\n\nFormats\n=======\n\npicfit currently supports the following image formats:\n\n- ``image/jpeg`` with the keyword ``jpg`` or ``jpeg``\n- ``image/png`` with the keyword ``png``\n- ``image/gif`` with the keyword ``gif``\n- ``image/bmp`` with the keyword ``bmp``\n- ``image/webp`` with the keyword ``webp``\n\nOperations\n==========\n\nNoop\n----\n\nThis operation will keep the actual size of the image without doing anything.\n\nYou have to pass the ``noop`` value to the ``op`` parameter to use this operation.\n\nResize\n------\n\nThis operation will able you to resize the image to the specified width and height.\n\nIf width or height value is 0, the image aspect ratio is preserved.\n\n-  **w** - The desired image's width\n-  **h** - The desired image's height\n\nYou have to pass the ``resize`` value to the ``op`` parameter to use this operation.\n\nThumbnail\n---------\n\nThumbnail scales the image up or down using the specified resample filter,\ncrops it to the specified width and height and returns the transformed image.\n\n-  **w** - The desired width of the image\n-  **h** - The desired height of the image\n\nYou have to pass the ``thumbnail`` value to the ``op`` parameter\nto use this operation.\n\nFlip\n----\n\nFlip flips the image vertically (from top to bottom) or\nhorizontally (from left to right) and returns the transformed image.\n\n-  **pos** - The desired position to flip the image, ``h`` will flip the image horizontally, ``v`` will flip the image vertically\n\nYou have to pass the ``flip`` value to the ``op`` parameter\nto use this operation.\n\nRotate\n------\n\nRotate rotates the image to the desired degree and returns the transformed image.\n\n-  **deg** - The desired degree to rotate the image\n\nYou have to pass the ``rotate`` value to the ``op`` parameter\nto use this operation.\n\nFlat\n----\n\nFlat draws a given image on the image resulted by the previous operation.\nFlat can be used only with the [multiple operation system].\n\n- **path** - the foreground image path\n- **color** - the foreground color in Hex (without ``#``), default is transparent\n- **pos** - the destination rectangle\n\nIn order to understand the Flat operation, please read the following `docs \u003chttps://github.com/thoas/picfit/blob/main/docs/flat.md\u003e`_.\n\nEffect\n------\n\nAdd effect to the given image.\n\n-  **filter** - The desired effect : ``blur``\n\nYou have to pass the ``effect`` value to the ``op`` parameter\nto use this operation.\n\nMethods\n=======\n\nDisplay\n-------\n\nDisplay the image, useful when you are using an ``img`` tag.\n\nThe generated image will be stored asynchronously on your\ndestination storage backend.\n\nA couple of headers (``Content-Type``, ``If-Modified-Since``) will be set\nto allow you to use an http cache system.\n\n\nRedirect\n--------\n\nRedirect to an image.\n\nYour file will be generated synchronously then the redirection\nwill be performed.\n\nThe first query will be slower but next ones will be faster because the name\nof the generated file will be stored in your key/value store.\n\nGet\n---\n\nRetrieve information about an image.\n\nYour file will be generated synchronously then you will get the following information:\n\n* **filename** - Filename of your generated file\n* **path** - Path of your generated file\n* **url** - Absolute url of your generated file (only if ``base_url`` is available on your destination storage)\n\nThe first query will be slower but next ones will be faster because the name\nof the generated file will be stored in your key/value store.\n\nExpect the following result:\n\n.. code-block:: json\n\n    {\n        \"filename\":\"a661f8d197a42d21d0190d33e629e4.png\",\n        \"path\":\"cache/6/7/a661f8d197a42d21d0190d33e629e4.png\",\n        \"url\":\"https://ds9xhxfkunhky.cloudfront.net/cache/6/7/a661f8d197a42d21d0190d33e629e4.png\"\n    }\n\nUpload\n------\n\nUpload is disabled by default for security reason.\nBefore enabling it, you must understand you have to secure yourself\nthis endpoint like only allowing the /upload route in your nginx\nor apache webserver for the local network.\n\nExposing the **/upload** endpoint without a security mechanism is not **SAFE**.\n\nYou can enable it by adding the option and a source\nstorage to your configuration file.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"storage\": {\n        \"src\": {\n          \"type\": \"[STORAGE]\"\n        }\n      },\n      \"options\": {\n        \"enable_upload\": true\n      }\n    }\n\nTo work properly, the input field must be named \"data\"\n\nTest it with the excellent httpie_:\n\n::\n\n    http -f POST localhost:3000/upload data@myupload\n\nYou will retrieve the uploaded image information in ``JSON`` format.\n\nMultiple operations\n===================\n\nMultiple operations can be done on the same image following a given order.\n\nFirst operation must be described as above then other operation are described in parameters ``op``.\nThe order of ``op`` parameters is the order used.\n\nEach options of the operation must be described with subparameters separated by\n``:`` with the operation name as argument to ``op``.\n\nExample of a resize followed by a rotation:\n\n.. code-block:: html\n\n    \u003cimg src=\"http://localhost:3001/display?w=100\u0026h=100\u0026path=path/to/file.png\u0026op=resize\u0026op=op:rotate+deg:180\"\n\nSecurity\n========\n\nRequest signing\n---------------\n\nIn order to secure requests and avoid unknown third parties to\nuse the service, the application can require a request to provide a signature.\nTo enable this feature, set the ``secret_key`` option in your config file.\n\nThe signature is an hexadecimal digest generated from the client\nkey and the query string using the HMAC-SHA1 message authentication code\n(MAC) algorithm.\n\nThe below python code provides an implementation example:\n\n.. code-block:: python\n\n    import hashlib\n    import hmac\n    import six\n    import urllib\n\n    def sign(key, *args, **kwargs):\n        m = hmac.new(key, None, hashlib.sha1)\n\n        for arg in args:\n            if isinstance(arg, dict):\n                m.update(urllib.urlencode(arg))\n            elif isinstance(arg, six.string_types):\n                m.update(arg)\n\n        return m.hexdigest()\n\nThe implementation has to sort keys in alphabetical order and encodes query string to generate a proper signature.\n\nThe signature is passed to the application by appending the ``sig``\nparameter to the query string; e.g.\n``w=100\u0026h=100\u0026sig=c9516346abf62876b6345817dba2f9a0c797ef26``.\n\nNote, the application does not include the leading question mark when verifying\nthe supplied signature. To verify your signature implementation, see the\n``signature`` command described in the `Tools`_ section.\n\nLimiting allowed sizes\n----------------------\n\nDepending on your use case it may be more appropriate to simply restrict the\nimage sizes picfit is allowed to generate. See the `Allowed sizes`_ section for\nmore information on this configuration.\n\nTools\n=====\n\nTo verify that your client application is generating correct signatures,\nuse the command::\n\n    $ picfit signature --key=abcdef \"w=100\u0026h=100\u0026op=resize\"\n    Query String: w=100\u0026h=100\u0026op=resize\n    Signature: 6f7a667559990dee9c30fb459b88c23776fad25e\n    Signed Query String: w=100\u0026h=100\u0026op=resize\u0026sig=6f7a667559990dee9c30fb459b88c23776fad25e\n\nError reporting\n===============\n\npicfit logs events by default in ``stderr`` and ``stdout``. You can implement sentry_\nto log errors using raven_.\n\nTo enable this feature, set ``sentry`` option in your config file.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"sentry\": {\n        \"dsn\": \"[YOUR_SENTRY_DSN]\",\n        \"tags\": {\n          \"foo\": \"bar\"\n        }\n      }\n    }\n\nDebug\n=====\n\nDebug is disabled by default.\n\nTo enable this feature set ``debug`` option to ``true`` in your config file:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"debug\": true\n    }\n\nCORS\n====\n\npicfit supports CORS headers customization in your config file.\n\nTo enable this feature, set ``allowed_origins``, ``allowed_headers`` and ``allowed_methods``,\nfor example:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"allowed_headers\": [\"Content-Type\", \"Authorization\", \"Accept\", \"Accept-Encoding\", \"Accept-Language\"],\n      \"allowed_origins\": [\"*.ulule.com\"],\n      \"allowed_methods\": [\"GET\", \"HEAD\"]\n    }\n\nImage engine\n============\n\nQuality\n-------\n\nThe quality rendering of the image engine can be controlled\nglobally without adding it at each request:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"engine\": {\n        \"quality\": 70\n      }\n    }\n\nWith this option, each image will be saved in ``70`` quality.\n\nBy default the quality is the highest possible: ``95``\n\nFormat\n------\n\nThe format can be forced globally without adding it at each request:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"engine\": {\n        \"format\": \"png\"\n      }\n    }\n\nWith this option, each image will be forced to be saved in ``.png``.\n\nBy default the format will be chosen in this order:\n\n* The ``fmt`` parameter if exists in query string\n* The original image format\n* The default format provided in the `application \u003chttps://github.com/thoas/picfit/blob/master/application/constants.go#L6\u003e`_\n\nOptions\n=======\n\nDeletion\n--------\n\nDeletion is disabled by default for security reason, you can enable\nit in your config:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_delete\": true\n      }\n    }\n\nYou will be able to delete root image and its children, for example if you upload an image with\nthe file path `/foo/bar.png`, you can delete the main image on stockage by sending the following HTTP request:\n\n\n::\n\n   DELETE https://localhost:3001/foo/bar.png\n\nor delete a child:\n\n::\n\n   DELETE https://localhost:3001/display/thumbnail/100x100/foo/bar.png\n\nIf you want to delete the main image and cascade its children, you can enable it in your config:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_delete\": true,\n        \"enable_cascade_delete\": true\n      }\n    }\n\nwhen a new image will be processed, it will be linked to the main image and stored in the kvstore.\n\nUpload\n------\n\nUpload is disabled by default for security reason, you can enable\nit in your config:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_upload\": true\n      }\n    }\n\nStats\n-----\n\nStats are disabled by default, you can enable them in your config.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_stats\": true\n      }\n    }\n\nIt will store various information about your web application (response time, status code count, etc.).\n\nTo access these information, you can visit: http://localhost:3001/sys/stats\n\nHealth\n------\n\nHealth is disabled by default, you can enable it in your config.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_stats\": true\n      }\n    }\n\nIt will show various internal information about the Go runtime (memory, allocations, etc.).\n\nTo access these information, you can visit: http://localhost:3001/sys/health\n\nProfiler\n--------\n\nProfiler is disabled by default, you can enable it in your config.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"enable_pprof\": true\n      }\n    }\n\nIt will start pprof_ then use the pprof tool to look at the heap profile:\n\n::\n\n   go tool pprof http://localhost:3001/debug/pprof/heap\n\nOr to look at a 30-second CPU profile:\n\n::\n\n   go tool pprof http://localhost:3001/debug/pprof/profile\n\nOr to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:\n\n::\n\n   go tool pprof http://localhost:3001/debug/pprof/block\n\nOr to collect a 5-second execution trace:\n\n::\n\n   wget http://localhost:3001/debug/pprof/trace?seconds=5\n\nLogging\n-------\n\nBy default the logger level is `debug`, you can change it in your config:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"logger\": {\n        \"level\": \"info\"\n      }\n    }\n\nLevels available are:\n\n* debug\n* info\n* error\n* warning\n\nAllowed sizes\n-------------\n\nTo restrict the sizes picfit is allowed to generate you may specify the\n``allowed_sizes`` option as an array of sizes. Note that if you omit a width or\nheight from a size it will allow requests that exclude height or width to\npreserve aspect ratio.\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"allowed_sizes\": [\n          {\"width\": 1920, \"height\": 1080},\n          {\"width\": 720, \"height\": 480},\n          {\"width\": 480}\n        ]\n      }\n    }\n\nIP Address restriction\n----------------------\n\nYou can restrict access to upload, stats, health, delete and pprof endpoints by enabling\nrestriction in your config:\n\n``config.json``\n\n.. code-block:: json\n\n    {\n      \"options\": {\n        \"allowed_ip_addresses\": [\n          \"127.0.0.1\"\n        ]\n      }\n    }\n\nDeployment\n==========\n\nIt's recommended that the application run behind a CDN for larger applications\nor behind varnish for smaller ones.\n\nProvisioning is handled by Ansible_, you will find files in\nthe `repository \u003chttps://github.com/thoas/picfit/tree/master/provisioning\u003e`_.\n\nYou must have Ansible_ installed on your laptop, basically if you have python\nalready installed you can do ::\n\n    $ pip install ansible\n\nRoadmap\n=======\n\nsee `issues \u003chttps://github.com/thoas/picfit/issues\u003e`_\n\nDon't hesitate to send patch or improvements.\n\n\nClients\n=======\n\nClient libraries will help you generate picfit urls with your secret key.\n\n* `picfit-go \u003chttps://github.com/ulule/picfit-go\u003e`_: a Go client library\n\nIn production\n=============\n\n- Ulule_: an european crowdfunding platform\n\nInspirations\n============\n\n* pilbox_\n* `thumbor \u003chttps://github.com/thumbor/thumbor\u003e`_\n* `trousseau \u003chttps://github.com/oleiade/trousseau\u003e`_\n\nThanks to these beautiful projects.\n\n.. _GOPATH: http://golang.org/doc/code.html#GOPATH\n.. _Redis: http://redis.io/\n.. _Redis cluster: https://redis.io/topics/cluster-tutorial\n.. _pilbox: https://github.com/agschwender/pilbox\n.. _varnish: https://www.varnish-cache.org/\n.. _persistence: http://redis.io/topics/persistence\n.. _Ansible: http://www.ansible.com/home\n.. _Ulule: http://www.ulule.com\n.. _sentry: https://github.com/getsentry/sentry\n.. _raven: https://github.com/getsentry/raven-go\n.. _httpie: https://github.com/jakubroztocil/httpie\n.. _pprof: https://blog.golang.org/profiling-go-programs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoas%2Fpicfit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoas%2Fpicfit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoas%2Fpicfit/lists"}