Skip to content

Commit

Permalink
fix bad logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Klathmon committed Jul 29, 2019
1 parent 11eeb25 commit b240460
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export async function optimizeImage (imageData, imageminOptions) {
// Await for imagemin to do the compression
const optimizedImageBuffer = await imagemin.buffer(imageBuffer, imageminOptions)

// If the optimization actually produced a smaller file, then return the optimized version
if (imageminOptions.onlyUseIfSmaller && optimizedImageBuffer.length < originalSize) {
return optimizedImageBuffer
} else {
// otherwize return the orignal
// If onlyUseIfSmaller is true, and the optimization actually produced a LARGER file, then return the original version
if (imageminOptions.onlyUseIfSmaller && optimizedImageBuffer.length > originalSize) {
return imageBuffer
} else {
return optimizedImageBuffer
}
}

Expand Down

0 comments on commit b240460

Please sign in to comment.