c# - Compress an iPhone image before upload -
this question has answer here:
- resize , saving image disk in monotouch 3 answers
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
Post a Comment