c# - ImageResizer auto scale down -
we've implemented base server imageresizer, have 1 more requirement. dealing user uploaded images. users want upload 5mb, 10mb, 30mb images (some surveillance footage , expected). don't want store full image size when on threshold. i'm no imaging expert - maybe should use client imageresizer api , set dpi, or maxwidth/maxheight? best practice scaling down image size?
look @ filecontentlength , ?maxwidth=1000&maxheight=1000 if on specified size?
look @ width/height of image , scale down accordingly? imageresizer has no way "get" image dimensions.
i have seen this post, don't want on our thumbnail (150x150) images obviously.
do care file size or type/resolution? if former,
if (post.filecontentlength > max_size){ //use imageresizer }else{ //store as-is } otherwise, use imageresizer , specify &maxwidth=3200&maxheight=3200.
if you're worried storage or bandwidth, file size might sufficient.
the downside leaving files as-is: metadata retained, , corrupted or non-web-friendly image formats stay web-unfriendly. high resolution images can compress tiny file sizes; there's no linear correlation, if consumers (like mobile devices) crash on high-megapixel images, have problem.
the upsize leaving files as-is: users may have optimized images, won't make 'worse'. metadata retained (if that's thing).
usually suggest modifying uploading images prior storage file size reasons, , re-compressing all images using imageresizer url api , slimmage.js ensure clients appropriate image device.
Comments
Post a Comment