
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
grunt-responsive-images
Advanced tools
Produces images at different sizes
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-responsive-images --save-dev
You'll also need to install Imagemagick CLI Tools.
brew install ImageMagick
Once both the plugin and ImageMagick have been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-responsive-images');
The responsive_images task will take your source image and create images at different resolutions for use with PictureFill or with srcset.
In your project's Gruntfile, add a section named responsive_images
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
responsive_images: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: Array
Default value:
{
name: "small",
width: 320,
height: 240,
quality: 1
},{
name: "medium",
width: 640,
height: 480,
quality: 1
},{
name: "large",
width: 1024,
height: 768,
quality: 1
}
An array of objects containing the sizes we want to resize our image to.
If both width and height are specified, then the image will be resized and cropped.
If a name
is specified, then the file will be suffixed with this name. e.g. my-image-small.jpg
If a name
is not specified, then the file will be suffixed with the width and/or height. e.g. my-image-320x240.jpg
Use suffix
for retina graphic filenames. e.g. my-image-320x240_x2.jpg
Use quality
to change the quality of an image (0.1, 0.2 ... 0.9, 1).
Type: String
Default value: -
The character used to seperate the image filename from the size name.
Using the default options will produce 3 responsive images - one at 320px wide, one at 640px wide and one at 1024px wide.
grunt.initConfig({
responsive_images: {
options: {},
files: {
'dest/mario-yoshi.jpg': 'test/assets/mario-yoshi.jpg'
}
}
})
In this example, we specify our own image sizes, including a retina graphic. We also specify our files with a wildcard.
grunt.initConfig({
responsive_images: {
options: {
sizes: [{
width: 320,
height: 240
},{
name: 'large',
width: 640
},{
name: "large",
width: 1024,
suffix: "_x2",
quality: 0.6
}]
},
files: [{
expand: true,
src: ['assets/**.{jpg,gif,png}'],
cwd: 'test/',
dest: 'tmp/'
}]
},
})
fatal error: spawn ENOENT
- Ensure Imagemagick CLI tools are installed. Try uninstalling and reinstalling them if you are having issues.In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
0.0.1 - Initial Commit
FAQs
Produce images at different sizes for responsive websites.
The npm package grunt-responsive-images receives a total of 307 weekly downloads. As such, grunt-responsive-images popularity was classified as not popular.
We found that grunt-responsive-images demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.