ASP.NET Image Resizing and Cropping [closed]
Asked Answered
K

3

6

I m looking for ASP.NET Image Resizing, Cropping
that is good in image re-sizing, cropping etc. Anyone know please share

Thankx In Advance

Klingensmith answered 17/8, 2011 at 14:33 Comment(4)
You already have GDI+, why do you need something else?Luke
because 3rd party API do best as compare to GDI. they have embedded croping algorithms etc which give you the exact image that u expect!Klingensmith
What's so hard about cropping? Just create a Bitmap and copy part of the original image with DrawImage. What exactly does GDI+ fail to provide?Luke
These pitfalls are why it's safer to use a library than write your own.Ileana
K
8

Well Experts!!! Last day I found http://www.imageresizing.net/ and its great. and good API. Works Great. Downloaded from Visual studio 2010 Extension Manager: http://nuget.org/.

Easy Steps to download API in VS-2010:

1). Install Extension http://nuget.org/.

enter image description here

3). Find and Install ImageResizing
enter image description here

4).Then Code: (I m using here cropping. you can use any) Documentation on imageresizing.net

string uploadFolder = Server.MapPath(Request.ApplicationPath + "images/");
FileUpload1.SaveAs(uploadFolder + FileUpload1.FileName);


//The resizing settings can specify any of 30 commands.. See http://imageresizing.net for details.
ResizeSettings resizeCropSettings = new ResizeSettings("width=200&height=200&format=jpg&crop=auto");

//Generate a filename (GUIDs are safest).
string fileName = Path.Combine(uploadFolder, System.Guid.NewGuid().ToString());

//Let the image builder add the correct extension based on the output file type (which may differ).
fileName = ImageBuilder.Current.Build(uploadFolder + FileUpload1.FileName, fileName, resizeCropSettings, false, true);

Try!!! its very awsumm and easy to use. thanks.

Klingensmith answered 5/11, 2011 at 6:17 Comment(2)
Hi Muhammad. Would I be able to use this tool if I have a hosted website (i.e. GoDaddy, etc)? That is to say, I can not walk over to the main server and install this component, as I do not own the server.Delsiedelsman
@jp2code, Hello, Yes you can use it on like GoDaddy type website mean where you cannot walk over to the main server and install component like ASPJPEG(in old version which I hv used). Its working fine for me on shared hosting.Klingensmith
H
0

This should give you the resizing you need: C# Tutorial - Image Editing: Saving, Cropping, and Resizing. As far as compression, that is going to be a function of the image format you choose e.g., PNG, JPG, GIF. To take control of that, look at the sample code here. Once you've saved to a compressed format, any further compression is (generally) a waste of time.

Harvest answered 17/8, 2011 at 14:46 Comment(0)
C
0

You really don't need a DLL for that. They are just three functions. Resizing, Cropping and Compression.

Its pretty much covered at Image resizing, cropping and compression using .NET

The only area that need some innovation is the area of cropping where one might need to visually crop images. For that use

  1. Image ASP.NET ( Demo here )
  2. Upload and Crop Images with jQuery, JCrop and ASP.NET
Comedo answered 17/8, 2011 at 14:47 Comment(1)
I disagree. There are over 29 pitfalls, and nobody ever avoids them all. The blog you're linking to uses a poor resampling algorithm and will cause a border artifact around the entire image, in addition to doing the cropping math incorrectly. I'm still waiting to see a single article on resizing that does everything right. At least the article you linked to doesn't seem to leak memory like most examples do. When it's this difficult to do a (seemingly) simple thing right, a library is a good idea.Ileana

© 2022 - 2024 — McMap. All rights reserved.