Swift function to duplicate images for thumbnail? : I'm making a photo gallery app.

I'm compressing the images

    NSData *imageData = UIImageJPEGRepresentation(image,0.5)

and then want to create a duplicate (for thumbnails) that I'll compress even further

    NSData *imageData = UIImageJPEGRepresentation(image,0.2)

I'm a little stuck on the middle step of how to create a duplicate, anyone know if there is a swift function for this?