IOS save image in document folder with set dimanation (width and height ) -
IOS save image in document folder with set dimanation (width and height ) -
get image uimageview , save in app document folder done problem when image big resolution how set fixed width , height image here code please help me
nsinteger n=100000000; nsuinteger r = arc4random_uniform(n) + 1; nsstring *myimagename=[nsstring stringwithformat:@"image%lu.png",(unsigned long)r]; nsdata *pngdata = uiimagepngrepresentation(self.myimage.image ) ; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentspath = [paths objectatindex:0]; //get docs directory nsstring *filepath = [documentspath stringbyappendingpathcomponent:myimagename]; //add file name [pngdata writetofile:filepath atomically:yes];
+ (uiimage*)imagewithimage:(uiimage*)image scaledtosize:(cgsize)newsize; { uigraphicsbeginimagecontext( newsize ); [image drawinrect:cgrectmake(0,0,newsize.width,newsize.height)]; uiimage* newimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); homecoming newimage; }
at first resize image, after save result.
ios image
Comments
Post a Comment