An easier option would be to use a reliable image module like ImageMagick, Imager, or even GD itself, to read the compressed jpeg, and rewrite (save) it to an uncompressed jpeg. Then attach.
$image = GD::Image->newFromJpegData($data, $truecolor)
These methods will create an image from a JPEG file. They work just like newFromPng() and newFromPngData(), and will accept the same filehandle and pathname arguments. The optional $truecolor (0/1) value can be used to override the global setting of trueColor() to specify if the return image should be palette-based or truecolor.
Bear in mind that JPEG is a 24-bit format, while GD is 8-bit. This means that photographic images will become posterized.