【问题标题】:How to use jCrop on a temporary image?如何在临时图像上使用 jCrop?
【发布时间】:2013-01-26 20:38:01
【问题描述】:

我有一个表格,您可以在其中从硬盘中选择一张图片,并且当您选择 选择了它立即在同一页面上显示的图片。

我想在缩略图演示中使用这张图片: http://deepliquid.com/projects/Jcrop/demos.php?demo=thumbnail 我还希望在更改输入文件时更改 jCrop 图像。

到目前为止,这是我的 PHP 文件:

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script class="jsbin"   src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script>
    function readURL(input) {
    if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $('#blah')
                    .attr('src', e.target.result)
                    .width(this.width)
                    .height(this.heigt);
            };
            reader.readAsDataURL(input.files[0]);
        }
    }
    </script>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>          
    <input type="file" name="image" id="image" onchange="readURL(this)" /><br />
    <label for="image">Image:</label>
    <img id="blah" src="#" alt="your image" />      
    </body>
    </html>

这可以按我的意愿工作,但我不知道如何将这张图片与 jCrop 一起使用,有什么想法吗?

【问题讨论】:

    标签: javascript jquery jcrop


    【解决方案1】:

    您必须将图像保存在临时文件夹中,因为 JCrop 的工作原理是获取原始图像并将其克隆到发生魔法的自定义容器中。

    因此,您使用 php 将发布的图像保存在 tmp 文件夹中,然后将其输出到 &lt;img&gt; 中的 &lt;div id = 'cropbox'&gt;(例如),然后是 $('#cropbox').Jcrop()

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 1970-01-01
      • 2016-06-22
      • 2014-05-22
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-21
      相关资源
      最近更新 更多