ASP.Net MVC Image Upload Resizing by downscaling or padding

前端 未结 2 831
夕颜
夕颜 2021-01-31 23:57

A user will be able to upload an image. If the image is greater than a set size I want to downsize it to that size. Obviously it doesn\'t have to match exactly due to ratios, t

2条回答
  •  鱼传尺愫
    2021-02-01 00:39

    You can just load the file into a bitmap object:

    http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx

    Then just check the width on the object. For the second part of your problem, I would recommend using a tool like ImageMagick

    http://www.imagemagick.org/script/index.php

    to accurately resize the first image or to create the background image and merge the two images together.

提交回复
热议问题