{"id":17462391,"url":"https://github.com/ben-ng/resize-stream","last_synced_at":"2025-03-28T06:31:54.230Z","repository":{"id":11755120,"uuid":"14287201","full_name":"ben-ng/resize-stream","owner":"ben-ng","description":"Resize images from files, streams, and multipart forms","archived":false,"fork":false,"pushed_at":"2013-11-11T05:21:39.000Z","size":300,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T20:16:51.541Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ben-ng.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-10T23:55:55.000Z","updated_at":"2017-01-28T18:53:17.000Z","dependencies_parsed_at":"2022-09-09T06:01:13.432Z","dependency_job_id":null,"html_url":"https://github.com/ben-ng/resize-stream","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-ng%2Fresize-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-ng%2Fresize-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-ng%2Fresize-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ben-ng%2Fresize-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ben-ng","download_url":"https://codeload.github.com/ben-ng/resize-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984241,"owners_count":20704787,"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":[],"created_at":"2024-10-18T08:43:27.836Z","updated_at":"2025-03-28T06:31:54.214Z","avatar_url":"https://github.com/ben-ng.png","language":"JavaScript","readme":"resize-stream\n=============\n\n[![Build Status](https://travis-ci.org/ben-ng/resize-stream.png?branch=master)](https://travis-ci.org/ben-ng/resize-stream)\n\nResizing images can suck. This library hopes to make that better.\n\n**Depends on ImageMagick, so make sure you have that installed**\n\n```\nvar rstream = require('resize-stream');\n\n// From a file path\nrstream.resizeFile('cat.jpg'\n  , {width: 50, height: 50} // See options documentation for more\n  , function (err, outStream, contentLength) {\n    // outStream is a readable stream\n    // contentLength makes it easy to .pipe() to S3\n  });\n\n// From a multipart form request\nrstream.resizeReq(req\n  , {width: 50, height: 50}\n  , function (err, outStream, contentLength) {\n    // etc\n  });\n\n// From a stream\nrstream.resizeStream(fs.createReadStream('cat.jpg')\n  , {width: 50, height: 50}\n  , function (err, outStream, contentLength) {\n    // etc\n  });\n```\n\nOptions\n-------\n\nThe second parameter is always an optional options hash. See the examples below for a visual guide.\n\n| Option Name | Default Value | Effect                                                             |\n|:-----------:|:-------------:|:------------------------------------------------------------------:|\n| width       | 320px         | The target width of the output image in pixels                     |\n| height      | 320px         | The target height of the output image in pixels                    |\n| fit         | `false`       | Fit the input image inside the bounds of the output image          |\n| crop        | `true`        | Crop the image instead of changing the aspect ratio or fitting     |\n| autoOrient  | `true`        | Rotate the image using its EXIF data                               |\n\nFit and Crop Examples\n---------------------\n\nSince these are hard to explain in words, here are some visual examples.\n\n### 450x450 Original\n![Original Image](https://raw.github.com/ben-ng/resize-stream/master/tests/fixtures/kitten.jpg \"Original Image\")\n[Credit](https://pusheen.com)\n\n| Target Dimensions | Crop  | Fit   | Result                                                                                                                      | Output Dimensions|\n|:-----------------:|:-----:|:-----:|:---------------------------------------------------------------------------------------------------------------------------:|:----------------:|\n| 200x400px         |`true` |Ignored|![Cropped](https://raw.github.com/ben-ng/resize-stream/master/tests/fixtures/expected/kitten.crop.jpg \"Cropped Image\")       | 200x400px        |\n| 200x400px         |`false`|`false`|![Not Fit](https://raw.github.com/ben-ng/resize-stream/master/tests/fixtures/expected/kitten.nocrop.nofit.jpg \"No Fit Image\")| 200x400px        |\n| 200x400px         |`false`|`true` |![Fit](https://raw.github.com/ben-ng/resize-stream/master/tests/fixtures/expected/kitten.nocrop.fit.jpg \"Fit Image\")         | 200x200px        |\n\nTo-Do\n-----\n * Stream API kind of stinks, we should be a duplex stream.\n * Finer control over the imagemagick commands\n\nLicense\n-------\nThe MIT License (MIT)\n\nCopyright (c) 2013 Ben Ng\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-ng%2Fresize-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fben-ng%2Fresize-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fben-ng%2Fresize-stream/lists"}