Page 3 of 6

resize image before upload to db

Posted: Mon Jul 08, 2013 4:31 pm
by Sean Kelley

Hi
Just wondering if you have made any progress on this issue.


resize image before upload to db

Posted: Mon Jul 08, 2013 4:33 pm
by Maryna Brodina

Hello! Please tell us your app name.


resize image before upload to db

Posted: Mon Jul 08, 2013 4:35 pm
by Sean Kelley

Name:
tack-web-file-api

I emailed the link 7 days ago


resize image before upload to db

Posted: Mon Jul 08, 2013 4:59 pm
by Maryna Brodina

Sorry, no progress for now. We'll continue testing and I update this post as soon as possible.


resize image before upload to db

Posted: Tue Jul 09, 2013 2:47 pm
by Maryna Brodina

Hi, could you clarify do you have problem with images from device memory or images captured with Camera?


resize image before upload to db

Posted: Wed Jul 10, 2013 11:43 am
by Sean Kelley

iphone ios6 file browsing=ok

iphone ios6 camera capture=rotate 90 degrees counter clockwise when saved but previews ok with no rotation

android 4.1.2 phone with android browser: when selecting existing image= no preview happens

android 4.1.2 phone with android browser:using camera=preview happens but no upload

android 4.1.2 with chrome browser: camera capture ok

android 4.1.2 with chrome browser: file browsing ok


resize image before upload to db

Posted: Thu Jul 11, 2013 2:19 pm
by Maryna Brodina

Hello! Still testing and have some problems with resolving this...


resize image before upload to db

Posted: Mon Jul 15, 2013 1:32 pm
by Maryna Brodina

Hello! Working on problem with rotating images on iPhone.


resize image before upload to db

Posted: Wed Jul 17, 2013 1:47 pm
by Maryna Brodina

Hello! Thank you for link you sent us! It helped a lot! To fix problem with uploading big files and image rotation on iOS devices you would need to use canvasresize plugin (https://gokercebeci.com/dev/download/...)
1) create JS assets with files jquery.canvasResize.js and jquery.exif.js
2) replace upload function with the following:
codefunction upload() {
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString&#46;length; i++) {
ia = byteString&#46;charCodeAt(i);
}
return new Blob([ab], {type: 'image&#47;jpeg'});
}
var serverUrl = 'https:&#47;&#47;api&#46;appery&#46;io&#47;rest&#47;1&#47;db&#47;files&#47;' + file&#46;name;
$&#46;canvasResize(file, {
width: 300,
height: 0,
crop: false,
quality: 80,
&#47;&#47;rotate: 90,
callback: function(data, width, height) {
$('<img>')&#46;attr('src', data);
var f = dataURItoBlob(data);
$&#46;ajax({
type: "POST",
beforeSend: function(request) {
request&#46;setRequestHeader("X-Appery-Database-Id", FileDB_settings['database_id']);
request&#46;setRequestHeader("X-Appery-Session-Token", localStorage&#46;getItem('token'));
request&#46;setRequestHeader("Content-Type", 'image&#47;jpeg');
},
url: serverUrl,
data: f,
processData: false,
contentType: false,
success: function(data) {
alert("success");
},
error: function(data) {
alert("error");
}
});
}
});
}/code


resize image before upload to db

Posted: Thu Jul 18, 2013 7:27 pm
by Sean Kelley

thanks for your help- after some initial testing this seems to work for iphone camera capture. I have not tested with android to make sure it still works. However, it works differently. The image that gets displayed in preview is the full size image, not the edited image. The resizing gets done on file upload in $.canvasResize(file, {...

How would one edit preview to show the modified file instead of the original?