{"id":13671813,"url":"https://github.com/scalableminds/gulp-image-resize","last_synced_at":"2025-04-27T18:31:47.559Z","repository":{"id":11457363,"uuid":"13919900","full_name":"scalableminds/gulp-image-resize","owner":"scalableminds","description":"Resizing images made easy - thanks to imagemagick.","archived":false,"fork":true,"pushed_at":"2019-08-27T09:42:43.000Z","size":2492,"stargazers_count":114,"open_issues_count":1,"forks_count":25,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-18T17:08:26.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"excellenteasy/grunt-image-resize","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scalableminds.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-10-28T08:02:56.000Z","updated_at":"2024-08-30T05:31:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/scalableminds/gulp-image-resize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalableminds%2Fgulp-image-resize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalableminds%2Fgulp-image-resize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalableminds%2Fgulp-image-resize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalableminds%2Fgulp-image-resize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalableminds","download_url":"https://codeload.github.com/scalableminds/gulp-image-resize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251187293,"owners_count":21549616,"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-08-02T09:01:19.392Z","updated_at":"2025-04-27T18:31:43.647Z","avatar_url":"https://github.com/scalableminds.png","language":"JavaScript","readme":"# [gulp](https://github.com/wearefractal/gulp)-image-resize [![Build Status](https://api.travis-ci.org/scalableminds/gulp-image-resize.svg?branch=master)](https://travis-ci.org/scalableminds/gulp-image-resize)\n\n\n\u003e Resizing images made easy - thanks to [GraphicsMagick](http://www.graphicsmagick.org/) or [ImageMagick](http://www.imagemagick.org/).\n\u003e Fork of [grunt-image-resize](https://github.com/excellenteasy/grunt-image-resize).\n\n## Install\n\nInstall with [npm](https://npmjs.org/package/gulp-image-resize)\n\n```\nnpm install --save-dev gulp-image-resize\n```\n\n### GraphicsMagick or ImageMagick\nMake sure GraphicsMagick or ImageMagick is installed on your system and properly set up in your `PATH`.\n\nUbuntu:\n\n```shell\napt-get install imagemagick\napt-get install graphicsmagick\n```\n\nMac OS X (using [Homebrew](http://brew.sh/)):\n\n```shell\nbrew install imagemagick\nbrew install graphicsmagick\n```\n\nWindows \u0026 others:\n\n[http://www.imagemagick.org/script/binary-releases.php](http://www.imagemagick.org/script/binary-releases.php)\n\nConfirm that ImageMagick is properly set up by executing `convert -help` in a terminal.\n\n\n## Example\n\n```js\nconst gulp = require('gulp');\nconst imageResize = require('gulp-image-resize');\n\ngulp.task('default', () =\u003e \n  gulp\n    .src('test.png')\n    .pipe(imageResize({\n      width : 100,\n      height : 100,\n      crop : true,\n      upscale : false\n    }))\n    .pipe(gulp.dest('dist')));\n```\n\n## API\n\n### imageResize(options)\n\n#### options.width\n\nType: `Number`  \nDefault value: `0` (only if height is defined)\n\nA number value that is passed as pixel or percentage value to imagemagick.\n\n\n#### options.height\n\nType: `Number`  \nDefault value: `0` (only if width is defined)\n\nA number value that is passed as pixel or percentage value to imagemagick.\n\n\n#### options.upscale\n\nType: `Boolean`  \nDefault value: `false`\n\nDetermines whether images will be upscaled. If set to `false` (default), image will be copied instead of resized if it would be upscaled by resizing.\n\n\n#### options.crop\n\nType: `Boolean`  \nDefault value: `false`\n\nDetermines whether images will be cropped after resizing to exactly match `options.width` and `options.height`.\n\n\n#### options.gravity\n\nType: `String`  \nDefault value: `Center`  \nPossible values: `NorthWest`, `North`, `NorthEast`, `West`, `Center`, `East`, `SouthWest`, `South`, `SouthEast`\n\nWhen cropping images this sets the image gravity. Doesn't have any effect, if `options.crop` is `false`.\n\n\n#### options.quality\n\nType: `Number`  \nDefault value: `1`\n\nDetermines the output quality of the resized image. Ranges from `0` (really bad) to `1` (almost lossless). Only applies to jpg images.\n\n\n#### options.format\n\nType: `String`  \nDefault value: Format of the input file  \nPossible values: `gif`, `png`, `jpeg` etc.\n\nOverride the output format of the processed file.\n\n#### options.filter\n\nType: `String`  \nPossible values: `Point`, `Box`, `Triangle`, `Hermite`, `Hanning`, `Hamming`, `Blackman`, `Gaussian`, `Quadratic`, `Cubic`, `Catrom`, `Mitchell`, `Lanczos`, `Bessel`, `Sinc`\n\nSet the filter to use when resizing (e.g. Catrom is very good for reduction, while hermite is good for enlargement).\n\n#### options.sharpen\n\nType: `Boolean | String`  \nDefault value: `false`\n\nSet to `true` to apply a slight unsharp mask after resizing.\nOr set a string to setup the unsharp. See [gm unsharp documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-unsharp). (e.g. '0.5x0.5+0.5+0.008')\n\n#### options.samplingFactor\n\nType: `Array[Cr, Cb]`  \nPossible values: `[2, 2]` for 4:2:2, `[1, 1]` for 4:1:1\n\nDefine chroma subsampling\n\n#### options.noProfile\n\nType: `Boolean`  \nDefault value: `false`\n\nSet to `true` to enforce removal of all embedded profile data like icc, exif, iptc, xmp\nand so on. If source files represent e.g. untouched camera data or images optimized for\nprint this may decrease image size drastically. Therefore this is probably wanted in\ncases where thumbnails are generated for web preview purposes. For details look for parameter _+profile \"*\"_ in the [gm profile documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-profile).\n\n#### options.interlace\n\nType: `Boolean`  \nDefault value: `false`\n\nSet to `true` to create interlaced images (scanline interlacing) from PNG, GIF or JPEG files\n(also known as \"progressive\" JPEG). For details look for parameter _-interlace \u0026lt;type\u0026gt;_ with the type value set to\n\"Line\" in the [gm profile documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-interlace).\n\n#### options.imageMagick\n\nType: `Boolean`  \nDefault value: `false`\n\nSet to `true` when using ImageMagick instead of GraphicsMagick.\n\n#### options.background\n\nType: `String`  \nPossible values: `none` to keep transparency, `beige` to set beige background, `#888` for gray.\n\nDefine background color (default is white), for example when converting SVG images to PNGs.\nSee [gm background documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-background)\n\n#### options.flatten\n\nType: `Boolean`  \nDefault value: `false`\n\nCombines image layers into one. Can be used for layered formats such as PNG. See [gm flatten documentation](http://www.graphicsmagick.org/GraphicsMagick.html#details-flatten).\n\n#### options.percentage\n\nType: `Number`  \nDefault value: `null`\n\nThe value that you want the image to be scaled to.\n\n\n#### options.cover\n\nType: `Boolean`\nDefault value: `false`\n\nDetermines whether images should cover the area specified by the width and height options. If set to `true`, the resized images will maintain aspect ratio by overflowing their dimensions as necessary, rather than treating them as maximum-size constraints.\n\n\n## More Examples\n\n```js\n// Converting from png to jpeg. No resizing.\ngulp.task('convert_png', () =\u003e \n  gulp\n    .src('test.png')\n    .pipe(imageResize({\n      format : 'jpeg'\n     }))\n    .pipe(gulp.dest('dist')));\n\n// Only specify one dimension. Output image won't exceed this value.\ngulp.task('width', () =\u003e \n  gulp\n    .src('test.png')\n    .pipe(imageResize({\n      width : 100\n    }))\n    .pipe(gulp.dest('dist')));\n\n// Convert with percentage value.\ngulp.task('percentage', () =\u003e\n  gulp\n    .src('test.png')\n    .pipe(imageResize({\n      percentage: 50\n    }))\n    .pipe(gulp.dest('dist')));\n```\n\n## Recommended modules\n\n* [concurrent-transform](https://github.com/segmentio/concurrent-transform): parallelize image resizing\n```js\nconst parallel = require(\"concurrent-transform\");\nconst os = require(\"os\");\n\ngulp.task(\"parallel\", () =\u003e \n  gulp\n    .src(\"src/**/*.{jpg,png}\")\n    .pipe(parallel(\n      imageResize({\n        width : 100\n      }),\n      os.cpus().length\n    ))\n    .pipe(gulp.dest(\"dist\")));\n```\n\n* [gulp-changed](https://www.npmjs.org/package/gulp-changed/): only resize changed images\n```js\nconst changed = require(\"gulp-changed\");\n\ngulp.task(\"changed\", () =\u003e\n  gulp\n    .src(\"src/**/*.{jpg,png}\")\n    .pipe(changed(\"dist\"))\n    .pipe(imageResize({\n      width : 100\n    }))\n    .pipe(gulp.dest(\"dist\")));\n```\n\n* [gulp-rename](https://www.npmjs.org/package/gulp-rename/): add a suffix or prefix\n```js\nconst rename = require(\"gulp-rename\");\n\ngulp.task(\"suffix\", () =\u003e\n  gulp\n    .src(\"src/**/*.{jpg,png}\")\n    .pipe(imageResize({\n      width : 100\n    }))\n    .pipe(rename(function (path) {\n      path.basename += \"-thumbnail\";\n     }))\n    .pipe(gulp.dest(\"dist\")));\n```\n\n## Tests\n\n1. You need both ImageMagick and GraphicsMagick installed on your system to run the tests.\n2. Install all npm dev dependencies `npm install`\n3. Install gulp globally `npm install -g gulp`\n4. Run `gulp test`\n\n\n## License\n\nMIT © [scalable minds](http://scm.io)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalableminds%2Fgulp-image-resize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalableminds%2Fgulp-image-resize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalableminds%2Fgulp-image-resize/lists"}