问题
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