<small id='jOrEp'></small><noframes id='jOrEp'>

        <legend id='jOrEp'><style id='jOrEp'><dir id='jOrEp'><q id='jOrEp'></q></dir></style></legend>

        • <bdo id='jOrEp'></bdo><ul id='jOrEp'></ul>
        <i id='jOrEp'><tr id='jOrEp'><dt id='jOrEp'><q id='jOrEp'><span id='jOrEp'><b id='jOrEp'><form id='jOrEp'><ins id='jOrEp'></ins><ul id='jOrEp'></ul><sub id='jOrEp'></sub></form><legend id='jOrEp'></legend><bdo id='jOrEp'><pre id='jOrEp'><center id='jOrEp'></center></pre></bdo></b><th id='jOrEp'></th></span></q></dt></tr></i><div id='jOrEp'><tfoot id='jOrEp'></tfoot><dl id='jOrEp'><fieldset id='jOrEp'></fieldset></dl></div>
      1. <tfoot id='jOrEp'></tfoot>

        将 PNG Base-64 字符串转换为 TIFF Base-64 字符串

        时间:2023-09-30

          <tfoot id='ZnEG3'></tfoot>

            <small id='ZnEG3'></small><noframes id='ZnEG3'>

            <legend id='ZnEG3'><style id='ZnEG3'><dir id='ZnEG3'><q id='ZnEG3'></q></dir></style></legend>
            • <bdo id='ZnEG3'></bdo><ul id='ZnEG3'></ul>
                <tbody id='ZnEG3'></tbody>
                <i id='ZnEG3'><tr id='ZnEG3'><dt id='ZnEG3'><q id='ZnEG3'><span id='ZnEG3'><b id='ZnEG3'><form id='ZnEG3'><ins id='ZnEG3'></ins><ul id='ZnEG3'></ul><sub id='ZnEG3'></sub></form><legend id='ZnEG3'></legend><bdo id='ZnEG3'><pre id='ZnEG3'><center id='ZnEG3'></center></pre></bdo></b><th id='ZnEG3'></th></span></q></dt></tr></i><div id='ZnEG3'><tfoot id='ZnEG3'></tfoot><dl id='ZnEG3'><fieldset id='ZnEG3'></fieldset></dl></div>

                • 本文介绍了将 PNG Base-64 字符串转换为 TIFF Base-64 字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用一个返回 PNG 编码的 base64 字符串的插件,我无法更改它,我必须使用它,但我真正需要的是 tiff 编码值(base-64).有没有办法做到这一点?

                  I'm using a plugin that returns a PNG encoded base64 string, I cannot change it, I must work with it, but what I really need is the tiff encoded value (base-64). Is there a way of doing this?

                  我尝试创建一个画布,加载 png base64,然后使用 toDataURL('image/tiff') 但经过一些研究,我发现不支持 tiff 作为 <代码>toDataURL().

                  I tried to create a canvas, load the png base64 and then used toDataURL('image/tiff') but after some research, I'd found that tiff is not supported as output of toDataURL().

                  有什么建议吗?

                  推荐答案

                  由于浏览器通常不支持 TIFF 作为目标文件格式,因此您必须通过使用 typed 构建文件结构来手动编码 TIFF 文件数组并符合 文件规范(请参阅 Photoshop 笔记 这里).可行:

                  As TIFF is not generally supported as target file-format in the browser, you will have to manually encode the TIFF file by building up the file-structure using typed arrays and in accordance with the file specifications (see Photoshop notes here). It's doable:

                  • 从画布中获取原始 RGBA 位图(记住 CORS 很重要)
                  • 在 DataView 视图中使用类型化数组,以便能够在未对齐的位置写入各种数据
                  • 构建文件头,定义最小的 TAGS 集并以您需要的方式对 RGBA 数据进行编码(未压缩很容易实现,或者简单的 RLE 压缩).
                  • 构造最终的文件缓冲区.从这里你有一个 ArrayBuffer 可以作为字节传输,可选:
                  • 使用 ArrayBuffer 和 tiff mime-type 转换为 Blob.
                  • 以ArrayBuffer为基础转换为Data-URI

                  更新 canvas-to-tiff 可用于将画布保存为 TIFF 图像(免责声明:我是作者).

                  Update canvas-to-tiff can be used to save canvas as TIFF images (disclaimer: I'm the author).

                  要使用 canvas-to-tiff 获取 Data-URI,您只需执行以下操作:

                  To get an Data-URI using canvas-to-tiff you can simply do:

                  CanvasToTIFF.toDataURL(canvasElement, function(url) {
                     // url now contains the data-uri.
                     window.location = url;    // download, does not work in IE; just to demo
                  });
                  

                  虽然,我建议使用 toBlob(),或者如果你想给用户一个链接,toObjectURL()(而不是 toDataURL).

                  Although, I would recommend using toBlob(), or if you want to give the user a link, toObjectURL() (instead of toDataURL).

                  var c = document.querySelector("canvas"),
                      ctx = c.getContext("2d");
                  
                  // draw some graphics
                  ctx.strokeStyle = "rgb(0, 135, 222)";
                  ctx.lineWidth = 30;
                  ctx.arc(200, 200, 170, 0, 2*Math.PI);
                  ctx.stroke();
                  
                  // Covert to TIFF using Data-URI (slower, larger size)
                  CanvasToTIFF.toDataURL(c, function(url) {
                    var a = document.querySelector("a");
                    a.href = url;
                    a.innerHTML = "Right-click this link, select Save As to save the TIFF";
                  })

                  <script src="https://cdn.rawgit.com/epistemex/canvas-to-tiff/master/canvastotiff.min.js">
                  </script>
                  <a href=""></a><br>
                  <canvas width=400 height=400></canvas>

                  var c = document.querySelector("canvas"),
                      ctx = c.getContext("2d");
                  
                  // draw some graphics
                  ctx.strokeStyle = "rgb(0, 135, 222)";
                  ctx.lineWidth = 30;
                  ctx.arc(200, 200, 170, 0, 2*Math.PI);
                  ctx.stroke();
                  
                  // Covert to TIFF using Object-URL (faster, smaller size)
                  CanvasToTIFF.toObjectURL(c, function(url) {
                    var a = document.querySelector("a");
                    a.href = url;
                    a.innerHTML = "Right-click this link, select Save As to save the TIFF";
                  })

                  <script src="https://cdn.rawgit.com/epistemex/canvas-to-tiff/master/canvastotiff.min.js">
                  </script>
                  <a href=""></a><br>
                  <canvas width=400 height=400></canvas>

                  这篇关于将 PNG Base-64 字符串转换为 TIFF Base-64 字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在不本地保存的情况下将 base64 数据传输到可读的图像流中 下一篇:将 svg 转换为 base64

                  相关文章

                    <bdo id='k8tiG'></bdo><ul id='k8tiG'></ul>
                  <i id='k8tiG'><tr id='k8tiG'><dt id='k8tiG'><q id='k8tiG'><span id='k8tiG'><b id='k8tiG'><form id='k8tiG'><ins id='k8tiG'></ins><ul id='k8tiG'></ul><sub id='k8tiG'></sub></form><legend id='k8tiG'></legend><bdo id='k8tiG'><pre id='k8tiG'><center id='k8tiG'></center></pre></bdo></b><th id='k8tiG'></th></span></q></dt></tr></i><div id='k8tiG'><tfoot id='k8tiG'></tfoot><dl id='k8tiG'><fieldset id='k8tiG'></fieldset></dl></div>

                • <tfoot id='k8tiG'></tfoot>

                  <legend id='k8tiG'><style id='k8tiG'><dir id='k8tiG'><q id='k8tiG'></q></dir></style></legend>

                  <small id='k8tiG'></small><noframes id='k8tiG'>