Last post Aug 25, 2011 02:16 PM by zioturo
Mar 17, 2008 04:00 PM|DJOuk|LINK
I am looking around the web trying to learn about the image functions in .Net and how I can use them to crop an Image and then save the file to a folder. The Process is basically:
The problem I keep having is that all the examples seem be dealing with drawing the image onto the page, i.e before page load. I want to make the image when they upload their image. All the examples are both 1) Drawing a rectangle 2) looking for the source
destination and a new one.
Can anyone recommend any links that explanes the features and uses of the Image Class? I am looking though MSDN but ideally something that involves making a new image in C-Sharp. Unless of course I do need to draw a rectangle etc etc....
Mar 17, 2008 10:16 PM|imagemaker|LINK
You might be interested in taking a look at the image editor that I just developed. A demonstration is available on the Projects page of my website:
http://www.wesnetdesigns.com/Projects/ImageEditor/tabid/114/Default.aspx. The basic ASP.Net/AJAX editor implements the image preview, cropping, rotation/flip, enhancements a MS AJAX 1.1 script control usable on any ASP.Net 2.0/AJAX website. The image editor
control wraps the basic editor with upload and file/folder handling for the DotNetNuke framework. Full source code of both controls, the dynamic image HttpHandler and the demo/sample DNN modules is available either in the downloads area of my site or as an
open source CodePlex project at http://www.codeplex.com/imageeditor
Mar 18, 2008 10:30 AM|DJOuk|LINK
I tried this:
filepath = "~/userimages/" + Profile.UserName + "/" + "1" + Convert.ToString(DateTime.Now.GetHashCode()) + addimage.FileName;
System.Drawing.Image userimage = System.Drawing.Image.FromFile(MapPath(filepath));
string thumbfilepath = "~/userimages/" + Profile.UserName + "/" + "1small" + Convert.ToString(DateTime.Now.GetHashCode()) + addimage.FileName;
userimage = crop(userimage,180,180);
imageclass.InsertImages(ticketid, Profile.userid, filepath, newclass.capcheck(title.Text));
Bitmap crop(System.Drawing.Image userimage, int Width, int Height)
Bitmap newimage = null;
newimage = new Bitmap(userimage, Width, Height);
I guess because Image and Bitmap are not the same. How would I convert Bitmap Back to image or can I perform similar code on System.Drawing.Image?
Jan 20, 2011 12:19 AM|awaishafeez86|LINK
Assuming that the visitor has uploaded the image and you have saved it somewhere in the file system.
Now you can use JQuery's JCrop library for image cropping.
Here is a very neat sample of Image Cropping using JCrop. Uptill now you will be able to capture the cropped area coordinates along with the width and height of selected rectangle into the hidden fields, say.
Now load tha uploaded image into memory and by using these coordinates crop and resize the target Images. Again save the byte in file system.
let me know if you require further help.
Happy coding !!!
Aug 25, 2011 07:45 AM|kumarrishav7|LINK
how can we cut the image and save it with the cropped coordinate,.,
Aug 25, 2011 02:16 PM|zioturo|LINK
The Piczard library (can be downloaded for free here: http://piczard.com/) includes an ASCX control that allows to manage image upload & crop procedures (SimpleImageUpload.ascx).
With one line of code you can configure the crop constraint/s.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Me.IsPostBack) Then
Me.Picture1.CropConstraint = New FixedCropConstraint(350, 350)
The example A.502 (included in the installer of the library) probably do everything you need.
Have a nice day