使用Javascript Image对象处理图像 [英] Using Javascript Image object to handle images

查看:126
本文介绍了使用Javascript Image对象处理图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在上传之前使用javascript预览图像以提供裁剪设施。为此,我在javascript中创建了一个Image对象。

I need to preview an image using javascript before upload to provide a crop facility. For this purpose, I create an Image object in javascript.

var image = new Image();

为了将大图像限制在有限的空间内,我使用<$访问图像的高度和宽度c $ c> image.width 和 image.height

To confine big images to a limited space, I access the height and width of the image using image.width and image.height

对于某些人来说图像,我发现这个值显示为零,当我检查图像对象时,发现 image.mimeType 具有值未指定错误(即使文件creationdate显示未指定的错误)。

For some of the images, I find that this value is shown as zero and for which when I inspected the image object, found that image.mimeType has the value Unspecified Error (Even the file creationdate shows unspecified error).

因此我无法预览这些图像。如何解决问题?

As such I am not able to preview those images. How do I solve the problem?

推荐答案

您将无法从客户端系统预览图像。您必须 将图像上传到服务器,并可以从那里显示图像预览

You won't be able to get a preview of image from the client system. You have to upload the image to a server and can show the image preview from there.

从中读取文件客户端系统是一种安全威胁,大多数浏览器都不允许这样做。在早期版本的IE中你可以得到它,但在新版本和其他浏览器中不可用。

Reading files from the client system is a security threat and most browsers won't allow that. In earlier versions of IE you can get that, but won't be available in newer versions and other browsers.

这篇关于使用Javascript Image对象处理图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆