javascript - QuillJS 编辑器 - 在编辑器内或上传前旋转上传图片

标签 javascript angularjs quill

我尝试上传 exif 数据中方向参数错误的图片。这会导致图像旋转不正确。

我需要在上传到 quillJS 编辑器之前旋转图像。

我该怎么做?有什么想法吗?

编辑:

.js

app.config(['ngQuillConfigProvider', function (ngQuillConfigProvider) {
  var toolbarModules = [                
            ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
            ['blockquote'],

            [{ 'list': 'ordered' }, { 'list': 'bullet' }],
            [{ 'indent': '-1' }, { 'indent': '+1' }],          // outdent/indent

            ['clean'],                                         // remove formatting button

            ['link', 'image', 'video']                         // link and image, video
        ];
  var toolbarFormats = ['bold', 'italic', 'underline', 'strike', 'blockquote', 'clean', 'list', 'link', 'image', 'video'];
  ngQuillConfigProvider.set({
    toolbar: toolbarModules
  }, undefined, 'Placeholder', toolbarFormats, undefined, undefined);
}]);

.html

<ng-quill-editor ng-model="data.description" toolbar="true" link-tooltip="true" image-tooltip="false" toolbar-entries="size bold list bullet italic underline strike align link" error-class="input-error"></ng-quill-editor>

最佳答案

我找到了解决方案。

包括这个, https://github.com/exif-js/exif-js

然后,将以下代码写入 quill.js:第 70744 行。

    node.onload = function () {
      EXIF.getData(node, function() {
        var allMetaData = EXIF.getAllTags(this);
        switch (allMetaData.Orientation) {
          case 1: // The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. 
            break;
          case 2: // The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
            node.style.transform = "rotateY(180deg)";
            break;
          case 3: // The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. 
            node.style.transform = "rotateY(360deg) rotate(180deg)";
            break;
          case 4: // Toe 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. 
            node.style.transform = "rotateX(180deg)";
            break;
          case 5: // The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. 
            node.style.transform = "rotateY(180deg) rotate(90deg)";
            break;
          case 6: // The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. 
            node.style.transform = "rotate(90deg)";
            break;
          case 7: // The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. 
            node.style.transform = "rotateY(180deg) rotate(270deg)";
            break;
          case 8: // The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
            node.style.transform = "rotate(270deg)";
            break;
          default:
            break;
        }
      });
    } 

quill.js: line 70744.

你可以得到follow cdn。我认为这是最新版本。
https://cdn.quilljs.com/1.3.6/quill.js

关于javascript - QuillJS 编辑器 - 在编辑器内或上传前旋转上传图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43676070/

相关文章:

javascript - 更准确的顺时针顶点排序

javascript - 全局 ajaxError 处理程序 jquery

javascript - 如何绑定(bind)到新的Set和Map对象?

xmlhttprequest - AngularJS 和位于不同域上的 Jersey Web 服务之间的通信。无法访问正确的 session

css - 内联样式而不是 quill 编辑器内置类,因为类在渲染 HTML 时不可用

angular - QuillJS 使用 Angular 7 + ngx-quill 将后续的 p 标签合并为一个

javascript - 从服务器拉取消息并在客户端渲染

javascript - 加载时增量 JQuery 函数

java - 带 Camel 和 Web 界面的自包含 jar?

javascript - 如何将现有数据读入 Quill JS