Rotate photo registration image

Maybe someone could help me with the code how to handle the situation when the user takes a picture for a registration with the phone in Horizontal or vertical position. The photo ID needs to be 90º right or 90º left, to be correct presented.

Thanks, Mario

I found this but how to write it correctly?

class CheckRotation {
/**

  • @param {string} src

  • @returns {Promise.}
    */
    orientation(src) {
    img = new Image();
    img.src = src;
    var width = img.width;
    var height = img.height;
    height = height + height // Double the height to get best
    //height = height + (height / 2) // Increase height by 50%

    if(width > height) {
    return “landscape”;
    } else {
    return “portrait”;
    }
    }
    }
    Backendless.ServerCode.addService( CheckRotation );

This is another code…

Hello @Mario_Ghersi

Seems like you are trying to use some example for browser, but our BusinessLogic is running in NodeJS env and there is no class Image.

I believe you need to try a 3rd party library, perhaps this one can help you jimp - npm

Regards, Vlad

I can recommend the image-js library: GitHub - image-js/image-js: Image processing and manipulation in JavaScript
Very powerful with a small footprint.

Regards

Maybe someone can help me how to connect the Service with the image and make the process. Error at 29 now.

Any example could help me to understand the logic to apply here.

Thanks in advance!

I can use this but first, I need to solve the JS code.

Could you provide what error do you catch?

Dear Dima

Thanks for your answer / question. I need some help to develop a simple service to rotate a landscape picture of a registration inside Backendless. Any idea or suggestion are welcome because I’m using Codeless and enter in JS is something outside of my knowledge but I’m learning.

Thanks, Mario

Hi @Mario_Ghersi,

your code on the screenshot looks good, but red highlighting of 29-d line means that there is some problem with this file. When you open this file, do you see any error message below the code or when hovering the mouse over the 29-d line? That would help us to identify the problem and help you to resolve it. Also, did you install image-js module before?

Regards,
Stanislaw

My solution was solved in a Heroku server outside Backendless

Also includes some code Face Recognition

Seems like an overkill/overengineering since Backendless can run nodejs code as API services. But if it works for you, then go for it!

Yes I’m agree with you. If someone can post a sample code in nodejs I will put all together in Backendless. Should be a resize image example around, I couldn’t find it yet, how to do it inside Backendless…

As a part of support we provide, we cannot write code for you, this is what our consulting services team does.
When you develop your own code with nodejs, to do it with backendless is nothing special about it - just plan JS class that has the functionality. You should start with a quick start guide to develop the most basic node API service, it is already described in our docs:
https://backendless.com/docs/bl-js/bl_advanced_quick_start_setup.html
Once it is done, you will have a feel for how nodejs API services work in backendless and after that you can do something specific for your app.

Hope this helps.

Regards,
Mark