@@ -45,6 +45,7 @@ exports.setBoundActionCreators = actions => {
45
45
const pluginDefaults = {
46
46
useMozJpeg : process . env . GATSBY_JPEG_ENCODER === `MOZJPEG` ,
47
47
stripMetadata : true ,
48
+ defaultQuality : 50 ,
48
49
}
49
50
let pluginOptions = Object . assign ( { } , pluginDefaults )
50
51
exports . setPluginOptions = opts => {
@@ -95,8 +96,8 @@ const generalArgs = {
95
96
sizeByPixelDensity : false ,
96
97
}
97
98
98
- const healOptions = ( args , defaultArgs ) => {
99
- let options = _ . defaults ( { } , args , defaultArgs , generalArgs )
99
+ const healOptions = ( { defaultQuality : quality } , args , defaultArgs ) => {
100
+ let options = _ . defaults ( { } , args , { quality } , defaultArgs , generalArgs )
100
101
options . quality = parseInt ( options . quality , 10 )
101
102
options . pngCompressionLevel = parseInt ( options . pngCompressionLevel , 10 )
102
103
options . pngCompressionSpeed = parseInt ( options . pngCompressionSpeed , 10 )
@@ -125,7 +126,6 @@ const healOptions = (args, defaultArgs) => {
125
126
126
127
let totalJobs = 0
127
128
const processFile = ( file , jobs , cb , reporter ) => {
128
- // console.log("totalJobs", totalJobs)
129
129
bar . total = totalJobs
130
130
131
131
let imagesFinished = 0
@@ -372,7 +372,7 @@ const queueJob = (job, reporter) => {
372
372
}
373
373
374
374
function queueImageResizing ( { file, args = { } , reporter } ) {
375
- const options = healOptions ( args , { } )
375
+ const options = healOptions ( pluginOptions , args , { } )
376
376
// Filter out false args, and args not for this extension and put width at
377
377
// end (for the file path)
378
378
const pairedArgs = _ . toPairs ( args )
@@ -476,7 +476,7 @@ function queueImageResizing({ file, args = {}, reporter }) {
476
476
}
477
477
478
478
async function generateBase64 ( { file, args, reporter } ) {
479
- const options = healOptions ( args , { width : 20 } )
479
+ const options = healOptions ( pluginOptions , args , { width : 20 } )
480
480
let pipeline
481
481
try {
482
482
pipeline = sharp ( file . absolutePath ) . rotate ( )
@@ -558,7 +558,7 @@ async function base64(arg) {
558
558
}
559
559
560
560
async function fluid ( { file, args = { } , reporter, cache } ) {
561
- const options = healOptions ( args , { } )
561
+ const options = healOptions ( pluginOptions , args , { } )
562
562
// Account for images with a high pixel density. We assume that these types of
563
563
// images are intended to be displayed at their native resolution.
564
564
let metadata
@@ -733,7 +733,7 @@ async function fluid({ file, args = {}, reporter, cache }) {
733
733
}
734
734
735
735
async function fixed ( { file, args = { } , reporter, cache } ) {
736
- const options = healOptions ( args , { } )
736
+ const options = healOptions ( pluginOptions , args , { } )
737
737
738
738
// if no width is passed, we need to resize the image based on the passed height
739
739
const fixedDimension = options . width === undefined ? `height` : `width`
@@ -843,7 +843,7 @@ async function notMemoizedtraceSVG({ file, args, fileArgs, reporter }) {
843
843
turnPolicy : potrace . Potrace . TURNPOLICY_MAJORITY ,
844
844
}
845
845
const optionsSVG = _ . defaults ( args , defaultArgs )
846
- const options = healOptions ( fileArgs , { } )
846
+ const options = healOptions ( pluginOptions , fileArgs , { } )
847
847
let pipeline
848
848
try {
849
849
pipeline = sharp ( file . absolutePath ) . rotate ( )
0 commit comments