Fine Uploader - Get Width & Height Dimensions once Image is Selected/Uploaded

喜夏-厌秋 提交于 2020-01-04 05:19:07

问题


Using fine-uploader i need to be able to get the selected file's original width and height dimensions in pixels so that i can use them for later use on my page. Is there a way to do this either once the file is selected or on the on complete success callback?


回答1:


Fine Uploader doesn't provide this type of data, but it's simple to determine the dimensions of an image yourself. First, convert the image file to an object URL (URL.createObjectURL(file)) then use that URL as the src attribute of an img element. Finally, after the <img> has completely rendered, check the width and height properties of the element. Fine Uploader does this internally when it is asked to validate an image file based on specific dimension limits. See the image validation code for an example.



来源:https://stackoverflow.com/questions/23758182/fine-uploader-get-width-height-dimensions-once-image-is-selected-uploaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!