Node.js: image resizing without ImageMagick

前端 未结 12 1636
离开以前
离开以前 2020-12-22 18:56

I\'m developing a web app on Node.js (+ express 4) where users can set their profile image by uploading it to the server. We already limit the file mimetype and max filesize

12条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 19:16

    If you don't need a large image, you can resize it on the client side before uploading it:

    Reading files in JavaScript using the File APIs

    Image resizing client-side with javascript before upload to the server

    Many users might have a good picture of themselves from a smartphone, and many of them are over 200kB. Note that client-provided data is not to be trusted, so server-side checks still apply.

提交回复
热议问题