uiimageview - Crop image in swift -


i trying crop image in swift. i'm trying implement like, user capture photo. once photo captured user allowed set crop area. i'm able image crop area, want crop image should resized particular width , height. is, if particular height or width smaller should resized.

enter image description here

this image should of frame of it's maximum width , height. adding transparency other area.

i had added code cropping

            let templayer = cashapelayer()              templayer.frame = self.view.frame                            let path = uibezierpath()              var endpoint: cgpoint!                            (var = 0; i<4; i++){                  let tag = 101+i                  let pointview = viewcrop.viewwithtag(tag)                  switch (pointview!.tag){                  case 101:                      endpoint = cgpointmake(pointview!.center.x-20, pointview!.center.y-20)                      path.movetopoint(endpoint)                  default:                      path.addlinetopoint(cgpointmake(pointview!.center.x-20, pointview!.center.y-20))                  }              }                            path.addlinetopoint(endpoint)              path.closepath()              templayer.path = path.cgpath                            templayer.fillcolor = uicolor.whitecolor().cgcolor              templayer.backgroundcolor = uicolor.clearcolor().cgcolor              imgreceiptview.layer.mask = templayer                            uigraphicsbeginimagecontextwithoptions(viewcrop.bounds.size, imgreceiptview.opaque, 0.0);              imgreceiptview.layer.renderincontext(uigraphicsgetcurrentcontext())              let cropimg = uigraphicsgetimagefromcurrentimagecontext()              uigraphicsendimagecontext();                            uiimagewritetosavedphotosalbum(cropimg, nil, nil, nil)              imgreceiptview.hidden = true                            let tempimageview = uiimageview(frame: cgrectmake(20,self.view.center.y-80, self.view.frame.width-40,160))              tempimageview.backgroundcolor = uicolor.graycolor()              tempimageview.image = cropimg              tempimageview.tag = 1001              tempimageview.layer.maskstobounds = true              self.view.addsubview(tempimageview)

any appreciable

thanks in advance

use library crop image user specific

https://github.com/kishikawakatsumi/pephotocropeditor

thanks hope you!


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -