 			t.progressive() if opts.progressive
 			t.compressionLevel(opts.compression)
 
-			return f.pipe(t).pipe(res)
+			setHeaders res, resHeaders
+			f.pipe(t).pipe(res)
+			return

	'image/png'
	'image/webp'
]


module.exports = (opts = {}) ->

	sharp.concurrency opts.concurrency

	(req, res, next) ->
		method = req.method.toUpperCase()
		return next() unless req.method.toUpperCase() in ['GET', 'HEAD']
		return next() unless req.path[0 .. opts.prefix.length - 1] is opts.prefix

		{w, h, g} = req.query
