Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
imagesize-loader
Advanced tools
A webpack image loader with extra size info for image.
npm install imagesize-loader --save
var image = require("imagesize!./file.png");
// => emits file.png to the output directory
// => returns an object
// => { width: 150, height: 50, type: "png", src: "file.png", bytes: 1234 }
config.output.imageFilename
// webpack.config.js
module.exports = {
output: {
imageFilename: '[name]-[hash].[ext]'
}
}
config.output.publicPath
The path/URL that gets prepended to the output filename - https://github.com/webpack/docs/wiki/configuration#outputpublicpath
var image = require('imagesize?name=[hash].[ext]!./file.png');
Note: This overrides the config output.imageFilename
.
var image = require('json!imagesize?json!./file.png');
Use this incase you'd want to add more properties to the output json.
[ext]
the extension of the resource[name]
the basename of the resource[path]
the path of the resource relative to the context
query parameter or option.[hash]
the hash or the content[<hashType>:hash:<digestType>:<length>]
optionally you can configure
hashType
s, i. e. sha1
, md5
, sha256
, sha512
digestType
s, i. e. hex
, base26
, base32
, base36
, base49
, base52
, base58
, base62
, base64
length
the length in chars[N]
the N-th match obtained from matching the current file name against the query param regExp
Source: https://github.com/webpack/loader-utils#interpolatename
// webpack.config.js
module.exports = {
output: {
publicPath: 'public/'
},
module: {
loaders: [
{
test: /\.(gif|jpeg|png)/,
loader: 'imagesize'
}
]
}
};
var result = require("./image.png");
// => {width: 500, height: 700, type: "png", src: "public/image.png", bytes: 1234}
FAQs
An image loader with extra size info
The npm package imagesize-loader receives a total of 8 weekly downloads. As such, imagesize-loader popularity was classified as not popular.
We found that imagesize-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.