epos4u Posted September 3, 2019 Share Posted September 3, 2019 any way we can read the exif from uploaded image to see what the rotation is thanks Link to comment Share on other sites More sharing options...
Sherzod Posted September 3, 2019 Share Posted September 3, 2019 1 hour ago, epos4u said: any way we can read the exif from uploaded image to see what the rotation is Hi, Exactly where would you like to get it? Link to comment Share on other sites More sharing options...
epos4u Posted September 3, 2019 Author Share Posted September 3, 2019 Hi Sherzod, using UnimFileUpload then display the image in UnimImage, selecting image from phone, camera rotation is not always correct to display exif to see what the rotation is, so can be rotated in code in UnimImage thanks, Link to comment Share on other sites More sharing options...
Sherzod Posted September 3, 2019 Share Posted September 3, 2019 12 minutes ago, epos4u said: using UnimFileUpload then display the image in UnimImage, selecting image from phone, camera rotation is not always correct to display exif to see what the rotation is, so can be rotated in code in UnimImage Hi, I will try to analyze. 1 Link to comment Share on other sites More sharing options...
epos4u Posted September 3, 2019 Author Share Posted September 3, 2019 thank you Sherzod Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 12 hours ago, epos4u said: using UnimFileUpload then display the image in UnimImage Hi, Can you use an UnimFileUploadButton instead? It seems I have a solution. Or another solution, you need to try to read EXIF data on the Delphi side. Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 Hi Sherzod, i don't mind using UnimFileUploadButton , if you have a solution that would be great thank you Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 1 hour ago, epos4u said: i don't mind using UnimFileUploadButton , if you have a solution that would be great OK. Try these steps... 1. UnimFileUploadButton1 2. CustomFiles: files/orientation.js function getOrientation(file, callback) { var reader = new FileReader(); reader.onload = function(e) { var view = new DataView(e.target.result); if (view.getUint16(0, false) != 0xFFD8) { return callback(-2); } var length = view.byteLength, offset = 2; while (offset < length) { if (view.getUint16(offset+2, false) <= 8) return callback(-1); var marker = view.getUint16(offset, false); offset += 2; if (marker == 0xFFE1) { if (view.getUint32(offset += 2, false) != 0x45786966) { return callback(-1); } var little = view.getUint16(offset += 6, false) == 0x4949; offset += view.getUint32(offset + 4, little); var tags = view.getUint16(offset, little); offset += 2; for (var i = 0; i < tags; i++) { if (view.getUint16(offset + (i * 12), little) == 0x0112) { return callback(view.getUint16(offset + (i * 12) + 8, little)); } } } else if ((marker & 0xFF00) != 0xFF00) { break; } else { offset += view.getUint16(offset, false); } } return callback(-1); }; reader.readAsArrayBuffer(file); } 3. private FOrientation: Byte; { Private declarations } 4. MainmForm -> OnCreate: procedure TMainmForm.UnimFormCreate(Sender: TObject); begin UnimFileUploadButton1.JSInterface.JSAddListener('change', 'function(sender){getOrientation(sender.getFiles()[0], function(orientation) {ajaxRequest(sender, "getOrientation", ["orientation="+orientation])})}'); end; 5. UnimFileUploadButton1 -> OnAjaxEvent: procedure TMainmForm.UnimFileUploadButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'getOrientation' then begin FOrientation := Params.Values['orientation'].ToInteger; end; end; Orientation values: Source: https://stackoverflow.com/questions/7584794/accessing-jpeg-exif-rotation-data-in-javascript-on-the-client-side Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 And here you can already use the value of FOrientation: procedure TMainmForm.UnimFileUploadButton1Completed(Sender: TObject; AStream: TFileStream); begin ... Case FOrientation of ... end; Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 Thank you Sherzod Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 Hi Sherzod, 4. MainmForm -> OnCreate: procedure TMainmForm.UnimFormCreate(Sender: TObject); begin UnimFileUploadButton1.JSInterface.JSAddListener('change', 'function(sender){getOrientation(sender.getFiles()[0], function(orientation) {ajaxRequest(sender, "getOrientation", ["orientation="+orientation])})}'); end; does not trigger on complete , not sure why Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 2 hours ago, epos4u said: does not trigger on complete , not sure why Hi, Yes, this is another event. When you select a file (take a picture), this event is triggered, in which you store a global variable that stores the last selected orientation of the 'image': 6 hours ago, Sherzod said: 5. UnimFileUploadButton1 -> OnAjaxEvent: procedure TMainmForm.UnimFileUploadButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'getOrientation' then begin FOrientation := Params.Values['orientation'].ToInteger; end; end; Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 Hi Sherzod, could you try it on the demo uniCloud please Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 5 minutes ago, epos4u said: could you try it on the demo uniCloud please Exactly in what sequence? Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 1 minute ago, Sherzod said: Exactly in what sequence? 1. click upload media 2. click on image 3. browse image and start upload 4. click on show media depending how the image was taken , that's why i need to able to rotate to view correctly thanks Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 Ok I will try. Link to comment Share on other sites More sharing options...
Sherzod Posted September 4, 2019 Share Posted September 4, 2019 But as you "remember", UnimFileUpload1 is used here instead of UnimFileUploadButton1 Link to comment Share on other sites More sharing options...
epos4u Posted September 4, 2019 Author Share Posted September 4, 2019 3 minutes ago, Sherzod said: But as you "remember", UnimFileUpload1 is used here instead of UnimFileUploadButton1 can you change it to UnimFileUploadButton1 to get the same results please if possible Link to comment Share on other sites More sharing options...
x11 Posted November 30, 2020 Share Posted November 30, 2020 On 9/4/2019 at 2:39 PM, Sherzod said: UnimFileUploadButton1.JSInterface.JSAddListener( how about TUnimFileUpload? theare is no JSInterface Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now