Created
February 10, 2018 09:08
-
-
Save caseyWebb/e1d0ffff930ae6ead177e0948fae3d62 to your computer and use it in GitHub Desktop.
GhostStoragePreprocessorSqipTransform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = class GhostStoragePreprocessorSqipTransform implements IGhostStoragePreprocessorTransform { | |
public async save(image: Image, targetDir?: string) { | |
const res = sqip({ filename: image.path }) | |
const sqipPath = image.path + '.sqip.svg' | |
const sqipImage = Object.assign({}, image, { | |
name: image.name + '.sqip.svg', | |
path: sqipPath, | |
mimetype: 'image/svg', | |
type: 'image/svg' | |
}) | |
await new Promise((resolve, reject) => | |
fs.writeFile(sqipPath, res.final_svg, (err) => err ? reject(err) : resolve())) | |
return [ | |
[image, targetDir], | |
[sqipImage, targetDir] | |
] as [Image, string][] | |
} | |
public async delete(image: Image, targetDir?: string) { | |
return [] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment