3
Answers

resize image to another image size in asp

prabha haran

prabha haran

8y
799
1
i have a image with size 800 and i upload a image and apply to that image while i am resizing the image is getting cropped and i need a orginal image to size to 800 help me
Answers (3)
1
prabha haran

prabha haran

NA 81 34.1k 8y
using C# coding system.drawing
1
Prashant Kumar

Prashant Kumar

216 8.8k 3.3m 8y
Hi Prabha,
 
Can you please let's clear where you are trying to update this images, if it sharePoint we ca do using image renditions sharepoint.
 
We will waiting for your update.
 
Thanks 
0
Maen Badwan

Maen Badwan

NA 661 146 7y
If you are uploading images from client side to server side (.NET C# or VB.NET code), the following forum post shows how you can resize or scale the image to a smaller size using native C# .NET classes:
https://stackoverflow.com/questions/6501797/resize-image-proportionally-with-maxheight-and-maxwidth-constraints

But if you are looking for more professional functions to resize the image and keep the quality and image data (such as DPI, TAGS, etc.), you can try using the .NET SizeCommand class from LEADTOOLS as shown in the following link:
https://www.leadtools.com/help/leadtools/v19/dh/l/imageprocessing-resizecommand.html
After resizing it, you can save it using the same original image's format and bits per pixel; and convert it to any other supported format.
 
The following code shows how you can load the image from stream, resize it and then save it to a different format using LEADTOOLS:
  1. ////////////////////////////////////////////////////////////////  
  2. ////////// After receiving the image stream at the server side//////////  
  3. ////////////////////////////////////////////////////////////////  
  4. RasterCodecs codecs = new RasterCodecs();  
  5. // Load the source image from MemoryStream or FileStream  
  6. RasterImage image = codecs.Load(srcFileStream);  
  7. // Resize the image to 800 x 600 pixels  
  8. SizeCommand command = new SizeCommand();  
  9. command.Width = 800;  
  10. command.Height = 600;  
  11. command.Flags = RasterSizeFlags.Resample;  
  12. command.Run(image);  
  13.   
  14. // Save the image back to disk as PNG format  
  15. codecs.Save(image, destFileName, RasterImageFormat.Png, 24);  
  16. // Clean Up  
  17. image.Dispose();  
  18. codecs.Dispose();  
  19. ////////////////////////////////////////////////////////////////