c# - Compress an iPhone image before upload -


this question has answer here:

i have following upload code, called after users selects image photo album:

public void picked(object sender, uiimagepickermediapickedeventargs e)     {         picker.dismissviewcontroller (false, null);          image.image = e.info [uiimagepickercontroller.originalimage] uiimage;          //get stream of image data         imagedata = image.image.aspng().asstream();         filename = filenamebox.text;          spinner.startanimating ();          thread t = new thread (uploadimage);         t.start ();     }      public void uploadimage()     {         //upload s3         amazon.s3.amazons3client s3 = new amazons3client ("my access key", "my secret key");          // create putobject request         putobjectrequest request = new putobjectrequest {             bucketname = "my bucket name",             key = filename          };           //put image data request         request.inputstream = imagedata;           // put image         putobjectresponse response = s3.putobject(request);          invokeonmainthread (stopspinning);     } 

everything works fine, iphone camera images have large size , upload slowly. looking way compress image before upload s3.

ive read other questions discussed scale function coming out in monotouch? trick? how use it?

i not looking crop image, compress , reduce size. how can achieved?

i looking monotouch example particularly rather objective c

the scale method of uiimage works reduces size (in pixels) of image. depending on requirements may or may not suit you. instead, experiment method uiimage.asjpeg(float quality), quality between 0 , 1. reduce quality of image without changing size in pixels.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -