Detect whether the loading image is taken from camera directly, when using smartphones

后端 未结 1 1620
礼貌的吻别
礼貌的吻别 2021-01-16 11:17

I am using html, tag:


On android and on many cellulars I have the ability to get the file directly by taki

相关标签:
1条回答
  • 2021-01-16 11:52

    I have found the solution by myself, so I want to participate it:

    What I needed is translate the binary data to exif data, so on exif.js, I added the following.

    jQuery.fn.getExif = function() {
        var exif;
        var bin;
        var bf;
        bin = atob(this.attr("src").split(',')[1]);
        if (bin) {
            bf = new BinaryFile(bin);
        }
        if (bf) {
            exif = EXIF.readFromBinaryFile(bf);
        }
        if (exif) {
            this.attr("exifdata", exif);
        }
        return exif;
    }
    

    and use the above on code - just get any exif value I want.

    The main issue is that the image should be rotated according to exif (if, i.e. the orientation is 90 degrees clockwise, so I should rotate 90 counterclockwise, in order to fix the orientation) - No problem on most devices, but there is a problem that persists on several devices, such as IPAD.

    IPAD (or Safari - I don't know exactly where might be the problem) do me a favour, and auto rotate the image, when I am loading it from file, so it is displayed always correctly.

    Now how can I know when to rotate the image and when not rotating it.

    Thanks :)

    0 讨论(0)
提交回复
热议问题