swift - How to get and save GIF Image from NSImageView to disk -


currently working on nsimageview, on user drags , drops image, , images gets saved disk. able save png , jpeg images, while saving gif images, saved single frame gif. imageview able display whole animated gif though.

my current implementation save image nsimageview disk is:

   let cgref = image.cgimageforproposedrect(nil, context: nil, hints: nil)    let newrep = nsbitmapimagerep(cgimage: cgref!)    newrep.size = image.size    let type = getbitmapimagefiletype(imagename.lowercasestring) // getbitmapimagefiletype: returns nsbitmapimagefiletype    let properties = type == .nsgiffiletype ? [nsimageloopcount: 0] : dictionary<string, anyobject>()    let data: nsdata = newrep.representationusingtype(type, properties: properties)!    data.writetofile(link, atomically: true) 

how should modify code able save frames of gif disk.


Comments