{"_id":"adaptive","_rev":"15-57daa664b9db149657a8e0e90ddc3c0c","name":"adaptive","description":"Simple adaptive image server based on smartcrop.js","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"name":"adaptive","version":"0.0.1","description":"Simple adaptive image server based on smartcrop.js","author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","main":"lib/index.js","bin":{"adaptive":"./bin/adaptive"},"scripts":{"start":"./bin/adaptive"},"dependencies":{"canvas":"^1.1.6","debug":"^2.0.0","express":"^4.9.7","minimist":"^1.1.0","request":"^2.45.0","send":"^0.9.3","smartcrop":"0.0.1"},"gitHead":"6c8eb4e3f73ce1d93a990e63f2fe4d5e1d6d86d0","_id":"adaptive@0.0.1","_shasum":"448dadfe1ca03bc816f7388f32c9235e2871a6b8","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"fgnass","email":"fgnass@gmail.com"},"maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"dist":{"shasum":"448dadfe1ca03bc816f7388f32c9235e2871a6b8","tarball":"https://registry.npmjs.org/adaptive/-/adaptive-0.0.1.tgz","integrity":"sha512-gEInqZ1ulVQla+8dOHhS8xOF+Ccu4kU0kMlJwtPLRM4Z970KYEtVwurBebiBb2ZdEYpNNW4vORh01L91Bid2eA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrSBfwX/EHU3yPWPpkhDwHKcTzHnPVofVSGUua/ts4PwIhAPqA+j6/CFqTpjPcR5O15lf4g0k6XnJNF4hKGAb52+xK"}]}},"0.0.2":{"name":"adaptive","version":"0.0.2","description":"Simple adaptive image server based on smartcrop.js","author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","main":"lib/index.js","bin":{"adaptive":"./bin/adaptive"},"scripts":{"start":"./bin/adaptive"},"dependencies":{"canvas":"^1.1.6","debug":"^2.0.0","express":"^4.9.7","minimist":"^1.1.0","mkdirp":"^0.5.0","request":"^2.45.0","send":"^0.9.3","smartcrop":"0.0.1"},"gitHead":"38af45110f9492c8b47538b91f94ad2488d41ce4","_id":"adaptive@0.0.2","_shasum":"feafaca7582eb96889d9ea934d27e051723e65f4","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"fgnass","email":"fgnass@gmail.com"},"maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"dist":{"shasum":"feafaca7582eb96889d9ea934d27e051723e65f4","tarball":"https://registry.npmjs.org/adaptive/-/adaptive-0.0.2.tgz","integrity":"sha512-HPW0T7bENffTZK4jAlugg2a15yDFRagqge9LsHNOrXuYWh8I5OwCBB6IgHvR3XZ7C82AriKoaR7vBSNDQ7jcGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDo9q7WUTJRe+WHuhg25WzAVMisr1ZOls9mdAtGnIQVAIhAJ3BPIvYiEcWYaTvKVI3zTaylafMF9FPlM2KRik2a0Sm"}]}},"0.0.3":{"name":"adaptive","version":"0.0.3","description":"Simple adaptive image server based on smartcrop.js","author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","main":"lib/index.js","bin":{"adaptive":"./bin/adaptive"},"scripts":{"start":"./bin/adaptive"},"dependencies":{"canvas":"^1.1.6","debug":"^2.0.0","express":"^4.9.7","minimist":"^1.1.0","mkdirp":"^0.5.0","request":"^2.45.0","send":"^0.9.3","smartcrop":"0.0.1"},"gitHead":"1a0b01a016b8b13b3b06a1e94f7a51aba4e32cd1","_id":"adaptive@0.0.3","_shasum":"afda014a3968bb291e5ce721ddde7d9fd6ac8634","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"fgnass","email":"fgnass@gmail.com"},"maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"dist":{"shasum":"afda014a3968bb291e5ce721ddde7d9fd6ac8634","tarball":"https://registry.npmjs.org/adaptive/-/adaptive-0.0.3.tgz","integrity":"sha512-f1ke671jQUzFrqSJT1cEVvsYSEGB06K73nXJYIj3ozXIUKWQ9BbKNbfWJb/IkaaEL9U+1lKv1xxPbDb9nsTm9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBvAMApHRSi6xUuRFj8ZTIitwWIduP8JUiswGvVNTPgaAiANLlSO33Sm59tYVLuCQ10D+qDxYOCmMklPlk0XIbceQg=="}]}},"0.0.4":{"name":"adaptive","version":"0.0.4","description":"Simple adaptive image server based on smartcrop.js","author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","main":"lib/index.js","bin":{"adaptive":"./bin/adaptive"},"scripts":{"start":"./bin/adaptive"},"dependencies":{"canvas":"^1.1.6","debug":"^2.0.0","express":"^4.9.7","minimist":"^1.1.0","mkdirp":"^0.5.0","request":"^2.45.0","send":"^0.9.3","smartcrop":"0.0.1"},"gitHead":"46813229b8691e6481d260d70203ae473f79a2dd","_id":"adaptive@0.0.4","_shasum":"7e5eb092747b777b6114925d27c3a3d98afcf9a9","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"fgnass","email":"fgnass@gmail.com"},"maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"dist":{"shasum":"7e5eb092747b777b6114925d27c3a3d98afcf9a9","tarball":"https://registry.npmjs.org/adaptive/-/adaptive-0.0.4.tgz","integrity":"sha512-MFqY+NVs9CW99WZ0UWT4ieknaE5UsZKaecrIDIJOTCTMW8hmQj6diGpveL+OTt9k6evt1oky3YP+1Fhudwq1dw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDDVr7kQujHLekP91StKhNseoV/g9HcOFSnHLurd8DOiQIhALxHir0wb3WNaFNF74iuhqC8AjYXi9PXGS3HP1Go89W8"}]}},"0.0.5":{"name":"adaptive","version":"0.0.5","description":"Simple adaptive image server based on smartcrop.js","author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","main":"lib/index.js","bin":{"adaptive":"./bin/adaptive"},"scripts":{"start":"./bin/adaptive"},"dependencies":{"canvas":"^1.1.6","debug":"^2.0.0","express":"^4.9.7","minimist":"^1.1.0","mkdirp":"^0.5.0","request":"^2.45.0","send":"^0.9.3","smartcrop":"0.0.1"},"gitHead":"0645811d45c268b83f583992d1cdb3a56339723c","_id":"adaptive@0.0.5","_shasum":"9a2e85d7f6ee2c97dfd31367b37373977d92c508","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"fgnass","email":"fgnass@gmail.com"},"maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"dist":{"shasum":"9a2e85d7f6ee2c97dfd31367b37373977d92c508","tarball":"https://registry.npmjs.org/adaptive/-/adaptive-0.0.5.tgz","integrity":"sha512-O8zGE3dwrxVWlFTLRYXHY6LgiMmDLUCpaub2yNnycKgl8KUf4cMWmzSV1PtOhwnizQ7wd4pMLoWz0Xc0KYRWuw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCd1C3JI26xEYjo3r2/0sy/xCVIGATIAp+CopBOwW4k/wIhALLfmmsR9+WOr4tjs9Nkz+zIQIwfa6qKwpGru/VrIvud"}]}}},"readme":"## adaptive\n\nSimple adaptive image server based on [smartcrop.js](https://github.com/jwagner/smartcrop.js)\n\n![Example](https://camo.githubusercontent.com/1086f55f4396e6c34f076b8f4a43c083fc5253d1/687474703a2f2f3239612e63682f73616e64626f782f323031342f736d61727463726f702f6578616d706c652e6a7067)\n_Image: [https://www.flickr.com/photos/endogamia/5682480447/](https://www.flickr.com/photos/endogamia/5682480447) by N. Feans_\n\n## Usage\n\nAdaptive exposes a single function that creates an [Express](expressjs.com) app:\n```js\nvar adaptive = require('adaptive');\n\nvar opts = {\n  secret: 'mysecret',\n  cache: '/tmp/adaptive'\n};\n\nadaptive(opts).listen(3000);\n```\n\nThe generated images will be stored in the filesystem. If you don't specify a\n`cache` directory, adaptive will store the files in the system's [temp\ndirectory](http://nodejs.org/api/os.html#os_os_tmpdir).\n\n## REST API\n\nYou can request images using the following URL pattern:\n\n`http://localhost:3000/<auth-key>/<width>x<height>/<src-url>`\n\n\nThe following URL will generate a 200x200 crop from the example image shown above:\n[http://localhost:3000/unsafe/200x200/https://farm6.staticflickr.com/5189/…](http://localhost:3000/unsafe/200x200/https://farm6.staticflickr.com/5189/5682480447_2b7f74b4bd_b.jpg)\n\n### Compression Settings\n\nYou can parametrize the JPEG compression by adding `:<quality>` where _quality_\nis a value from 0 to 100, optionally followed by a `p` to create a progressive\nJPEG.\n\nExamples:\n\n* `http://localhost:3000/unsafe/200x200:75/<src-url>` 75% quality\n* `http://localhost:3000/unsafe/200x200:p/<src-url>` progressive, default quality\n* `http://localhost:3000/unsafe/200x200:75p/<src-url>` 75% quality, progressive\n\n\n## Security\n\nIn order to prevent DoS attacks _adaptive_ allows you to specify shared secret\nthat is used to generate a [hash-based message authentication code](\nhttp://en.wikipedia.org/wiki/Hash-based_message_authentication_code).\n\nThe web server that serves a page which contains adaptive images generates an\n_auth key_ for the _options_ and _src-url_.\n\nWhen end-users access the page and thus load the image, adaptive generates\na key using the same algorithm. If both auth keys match, the request is\nprocessed.\n\n### Generating auth-keys\n\nAdaptive uses standard HMAC with SHA1 signing.\n\nIn order to convert `http://example.com/unsafe/200x200/path/to/image.jpg`\ninto a _safe_ URL we must sign the part `200x200/path/to/image.jpg`\n\n1. Generate a signature of that part using HMAC-SHA1 with the _secret_.\n2. Encode the signature as base64.\n3. Replace `+` by `-`\n4. Replace `/` by `_`\n5. Replace `unsafe` at the beginning of the URL with the generated key\n\n## CLI\n\nAdaptive also comes with a binary that can be used to start a HTTP server:\n\n`adaptive -p <port> -s <secret> -c <cache-dir>`\n\nAlternatively the options can be set using environment variables:\n\n`PORT=3000 SECRET=mysecret npm start`\n\n## Deploying to Heroku/dokku\n\nThe easiest way to deploy _adaptive_ to Heroku or a dokku instance is to create\nan empty project with nothing but a `package.json`:\n```json\n{\n  \"name\": \"my-adaptive-images\",\n  \"private\": true,\n  \"version\": \"0.0.1\",\n  \"dependencies\": { \"adaptive\": \"*\" },\n  \"scripts\": { \"start\": \"adaptive\" }\n}\n```\n\n### Prerequisites\n\nAdpative uses [node-canvas](https://github.com/Automattic/node-canvas) which in\nturn is based on Cairo. For system-specific installation instructions please\nrefer to the [wiki](https://github.com/Automattic/node-canvas/wiki/).\n\nDokku's Ubuntu image provides all required dependencies except for `libgif`.\nThe easiest way to add it is to do this:\n```\necho https://github.com/fgnass/buildpack-install > .buildpacks\necho https://github.com/heroku/heroku-buildpack-nodejs >> .buildpacks\necho apt-get install -y libgif-dev > .install\n\ngit add .buildpacks .install\ngit commit -m \"add node-canvas prerequisites\"\n```\n\n### Logging\n\nYou can turn on [debug](https://www.npmjs.org/package/debug) output by setting\nthe `DEBUG` env var to `adaptive:*`\n\n## The MIT License (MIT)\n\nCopyright (c) 2014 Felix Gnass\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","maintainers":[{"name":"fgnass","email":"fgnass@gmail.com"}],"time":{"modified":"2022-06-13T02:25:00.963Z","created":"2014-10-15T21:08:00.883Z","0.0.1":"2014-10-15T21:08:00.883Z","0.0.2":"2014-10-17T13:37:12.627Z","0.0.3":"2014-10-17T14:05:05.371Z","0.0.4":"2014-10-17T15:46:35.062Z","0.0.5":"2014-10-21T15:26:24.708Z"},"author":{"name":"Felix Gnass","email":"fgnass@gmail.com"},"license":"MIT","readmeFilename":"README.md","users":{"roka":true,"brunocalou":true}}