
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
responsive-image-directory
Advanced tools
Given a `src` directory of images, the script creates a clone of the directory and its contained images at the provided `dest` path, but with multiple sizes of each image, based on the sizes specified in the settings.
Given a src
directory of images, the script creates a clone of the directory and its contained images at the provided dest
path, but with multiple sizes of each image, based on the sizes specified in the settings.
image.jpg
becomes image-600w.jpg
.dest
directory are deleted if the corresponding files or directories no longer exist int he src
directory.resizeOriginal
option is true
, the original version of the image will be overwritten by the biggest responsive version of the image generated.npm install responsive-image-directory
const responsiveImages = require('responsive-images');
responsiveImages(settings);
src
required - the path to the source directory of images.
dest
required - the path to the output directory of the generated images.
sizes
required - an array of maxWidth
and maxHeight
combinations. Responsive versions of each image will be generated based on these values.
logPath
optional - path to a file to save the verbose log of image operations to.
resizeOriginal
optional - if true
, the original image from the src
directory will be overwritten with the largest responsive version of the image in the dest
directory.
skipExisting
optional; default === true - if true
, existing responsive images in the dest
directory which are newer than the original image in the src
directory will not be regenerated.
batchSize
optional; default === 10 - the number of images from the src
directory to process at a time.
maxQuality
optional; default === 90 - the maximum allowed quality setting for JPEG compression. If dynamicQualityParams
(See below) is not passed, then the quality setting for JPEG compression will be fixed to this value for all images.
minQuality
optional; default === 1 - the minimum allowed quality setting for JPEG compression.
dynamicQualityParams
optional - an object that must contain width
, height
and maxBytes
.
Allows the quality of each set of responsive images to be adjusted on the fly, such that the file sizes of the responsive images to conform closely to the params in dynamicQualityParams
.
dynamicQualitySetting
exampleOptions
...
"dynamicQualityParams": {
"width": 1440,
"height": 1080,
"maxBytes": 204800
}
"maxQuality": 90,
"minQuality": 10,
"sizes": [{
"maxWidth": 400,
"maxHeight": 300
}, {
"maxWidth": 800,
"maxHeight": 600
}, {
"maxWidth": 1600,
"maxHeight": 1200
}]
...
Assume you have one large image in the src
directory with dimensions of 4000px x 2000px
. Based on the sizes
setting above, three responsive versions of the image would be generated in the dest
directory with the following dimensions:
1600px X 800px
800px x 400px
400px x 200px
First, the quality of the largest image in the set will be determined as follows.
dynamicQualityParams
setting tells us that a 1440px
x 1080px
image has a maxBytes
setting of 204800 bytes
.1600px
x 800px
image has a proportional maxBytes
setting of 168559
bytes.
maxBytes
will be set to the file size of the original image.1600px x 800px
image at the maxQuality
setting, and if the resulting image is bigger than 168559
bytes, it will reduce the quality and try again, repeating this process until the resulting image is just below 168559
bytes.
minQuality
setting, even if the resulting image is bigger than maxBytes
.The final quality
value above is then used to generate each other image in the set.
Assuming the final quality
setting of the largest image was 75
, then the 800px x 400px
image and 400px x 200px
will each be generated with a quality setting of 75
.
{
"src": "./input",
"dest": "./output",
"logPath": "./image-log.json",
"resizeOriginal": true,
"skipExisting": true,
"batchSize": 20,
"dynamicQualityParams": {
"width": 1440,
"height": 1080,
"maxBytes": 204800
},
"maxQuality": 90,
"minQuality: 10,
"sizes": [
{
"maxWidth": 400,
"maxHeight": 300
},
{
"maxWidth": 50000,
"maxHeight": 40000
},
{
"maxWidth": 4000,
"maxHeight": 3000
},
{
"maxWidth": 20000,
"maxHeight": 3000
}
]
}
FAQs
Given a `src` directory of images, the script creates a clone of the directory and its contained images at the provided `dest` path, but with multiple sizes of each image, based on the sizes specified in the settings.
We found that responsive-image-directory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.