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

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -