Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. var responsive = require('gulp-responsive');
  2. var load = require('gulp-load-plugins')();
  3.  
  4. gulp.task('resize-img', function () {
  5. return gulp.src('img/*.{jpg,png}')
  6. .pipe(load.responsive({
  7. '*.jpg': [{
  8. width: 100,
  9. rename: {
  10. suffix: '-thumb',
  11. }
  12. }, {
  13. width: 300,
  14. rename: {
  15. suffix: '-medium',
  16. // extname: '.jpg',
  17. },
  18. }, {
  19. width: 900,
  20. rename: {
  21. suffix: '-big',
  22. },
  23. // Do not enlarge the output image if the input image are already less than the required dimensions.
  24. withoutEnlargement: true,
  25. }],
  26.  
  27. '*.png': [{
  28. width: 100,
  29. rename: {
  30. suffix: '-thumb',
  31. }
  32. }, {
  33. width: 300,
  34. rename: {
  35. suffix: '-medium',
  36. // extname: '.jpg',
  37. },
  38. }, {
  39. width: 900,
  40. rename: {
  41. suffix: '-big',
  42. },
  43. // Do not enlarge the output image if the input image are already less than the required dimensions.
  44. withoutEnlargement: true,
  45. }]
  46.  
  47. }, {
  48. // Global configuration for all images
  49. // The output quality for JPEG, WebP and TIFF output formats
  50. quality: 70,
  51. // Use progressive (interlace) scan for JPEG and PNG output
  52. progressive: true,
  53. // Strip all metadata
  54. withMetadata: false,
  55. // Do not emit the error when image is enlarged.
  56. errorOnEnlargement: false,
  57. }))
  58. .pipe(gulp.dest('img/dist'));
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement