在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):rizalp/gulp-sharp开源软件地址(OpenSource Url):https://github.com/rizalp/gulp-sharp开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-sharpThis Project Is No Longer Maintained Because of other occupation, I can't maintain it anymore. If you find this project usefull, please fork it. Please note that new issues / pr messages will be ignored. Thanks.
Prerequisites
On Ubuntu 14.x and 15.04 the default libvips package is not compatible with versions of Sharp. To manually install VIPS from source, follow the instructions at Build VIPS on Ubuntu The source is available from the VipsWiki site. For other system, more info can be seen at sharp Prerequisites. InstallationIn your project directory, type:
Then, you can use
Usage examples
The former way is more compatible with other gulp plugins (since it just modify the contents of the file ( First Way: var gulp = require('gulp');
var gulpSharp = require('gulp-sharp');
gulp.task('image-resize', function(){
return gulp.src( 'content/**/*.+(jpeg|jpg|png|tiff|webp)' )
.pipe(gulpSharp({
resize : [1280, 800],
max : true,
quality : 60,
progressive : true
}))
.pipe(gulp.dest('output'));
}); Second Way, by specifying var gulp = require('gulp');
var gulpSharp = require('gulp-sharp');
gulp.task('image-resize', function(){
return gulp.src( 'content/**/*.+(jpeg|jpg|png|tiff|webp)', {read : false} )
.pipe(gulpSharp({
resize : [1280, 800],
max : true,
quality : 60,
progressive : true
}))
.pipe(gulp.dest('output'));
}); OptionsType: This options.resizeType: Required property. Example:
options.withoutEnlargementType: Optional. Do not enlarge the output image if the input image width or height are already less than the required dimensions. options.maxType: Optional. Use this if you'd like to preserve aspect ratio of the image when you specify both Both width and height must be provided via resize otherwise the behaviour will default to crop. options.cropType: Optional. Crop the image with the options.interpolateWithType: Optional. You can omit this property, and options.embedWhiteType: Optional. Embed the resized image on a white background of the exact size specified. options.embedBlackType: Optional. Embed the resized image on a black background of the exact size specified. options.rotateType: Optional. Rotate the output image by either an explicit angle ( options.sharpenType: Optional. Perform a mild sharpen of the output image. This typically reduces performance by 10%. options.gammaType: Optional. Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of 1/ Recomended value is This can improve the perceived brightness of a resized image in non-linear colour spaces. JPEG input images will not take advantage of the shrink-on-load performance optimisation when applying a gamma correction. options.grayscaleType: Optional. Convert to grayscale options.withMetadataType: Optional. Include all metadata (ICC, EXIF, XMP) from the input image in the output image. The default behaviour is to strip all metadata. options.qualityType: Optional. The output quality to use for lossy JPEG, WebP and TIFF output formats. The default quality is 80. This property is ignored for PNG images options.progressiveType: Optional. Use progressive (interlace) scan for JPEG and PNG output. This typically reduces compression performance by 30% but results in an image that can be rendered sooner when decompressed. options.compressionLevelType: Optional. An advanced setting for the zlib compression level of the lossless PNG output format. The default level is 6. This property is ignored if image input is not options.outputType: Optional. Use this property if you'd like to convert image input into another image format. LicenseMIT © Mohammad Shahrizal Prabowo |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论