I dont believe you can. You would only be able to resize after upload, but you could do it before SAVE. You dont have access the client's machine to adjust their files.
You may be able to do something with a 3rd party component, but not with native Asp.Net.
Have you read the book? - ASP.Net 3.5 CMS Development (now on Kindle)
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
You can't without resorting to Flash or Java. This has to be done on the client so the ajaxuploader won't really help. You don't have the capabilities on a browser that you do on a server, and especially since you don't know what the user's browser will
be. There aren't any functions to resize the image in a specific format and manipulate it that will work.
HTML 5 does provide some new powerful javascript features, but it is still just a recommendation and not a complete standard yet. There are examples of HTML 5 being used to resize images, but I have not found any that resize and upload. You would end up
needing a different upload method as well. It may not even work because this would normally be a security violation because you would attempt to access a file on the client's computer outside the browser sandbox. The file input isn't meant to be manipulated
like this.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
You can do this with HTML5 using FileAPI and Canvas.
Keep in mind browser support may be an issue when do things this way but it should be a viable option in the near future.
jrahma
Member
364 Points
650 Posts
how resize this image before uploading
Jan 22, 2013 06:43 PM|LINK
Hi,
I am using this code to upload using Ajaxuploader:
using (Stream stream = item.OpenStream()) { using (System.Drawing.Image img = System.Drawing.Image.FromStream(stream)) { img.Save(Server.MapPath(String.Format("{0}/{1}/posts/{2}/{3}.png", Application["MemberMediaDirectory"], Session["volow_member_guid"], RouteData.Values["GUID"], image_guid)), ImageFormat.Png); } }I want to know how can I resize the image before uploading to 906width X 360height?
Technology News @ www.JassimRahma.com
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: how resize this image before uploading
Jan 22, 2013 06:50 PM|LINK
I dont believe you can. You would only be able to resize after upload, but you could do it before SAVE. You dont have access the client's machine to adjust their files.
You may be able to do something with a 3rd party component, but not with native Asp.Net.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
markfitzme
Star
14471 Points
2236 Posts
Re: how resize this image before uploading
Jan 22, 2013 06:50 PM|LINK
You can't without resorting to Flash or Java. This has to be done on the client so the ajaxuploader won't really help. You don't have the capabilities on a browser that you do on a server, and especially since you don't know what the user's browser will be. There aren't any functions to resize the image in a specific format and manipulate it that will work.
HTML 5 does provide some new powerful javascript features, but it is still just a recommendation and not a complete standard yet. There are examples of HTML 5 being used to resize images, but I have not found any that resize and upload. You would end up needing a different upload method as well. It may not even work because this would normally be a security violation because you would attempt to access a file on the client's computer outside the browser sandbox. The file input isn't meant to be manipulated like this.
jrahma
Member
364 Points
650 Posts
Re: how resize this image before uploading
Jan 22, 2013 07:09 PM|LINK
so what's the solution?
Technology News @ www.JassimRahma.com
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: how resize this image before uploading
Jan 22, 2013 07:44 PM|LINK
Look at a 3rd party component or do it server side. Those are your options, as stated
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
jrahma
Member
364 Points
650 Posts
Re: how resize this image before uploading
Jan 22, 2013 07:58 PM|LINK
do you recommand any?
Technology News @ www.JassimRahma.com
jprochazka
Contributor
4896 Points
740 Posts
Re: how resize this image before uploading
Jan 22, 2013 07:59 PM|LINK
You can do this with HTML5 using FileAPI and Canvas.
Keep in mind browser support may be an issue when do things this way but it should be a viable option in the near future.
Take a look at this article:
https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
Check out the comments on this page as well.
swetha sanka...
Member
2 Points
1 Post
Re: how resize this image before uploading
Jan 22, 2013 08:07 PM|LINK
Photoshop if you have it already. Image->Size. Change it to your desired pixels.
If you want an open source version of photo editor, try GIMP.
Trust this helps.
Good luck.
Swetha
vijay_myl
Contributor
5070 Points
1068 Posts
Re: how resize this image before uploading
Jan 23, 2013 03:45 AM|LINK
Hi...
You can refer the below link to resize the image a before upload ............
http://www.dotnetcode.in/2012/06/resize-image-and-upload-in-to-server-in.html
My .NET blog
Submit Article
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: how resize this image before uploading
Jan 23, 2013 01:28 PM|LINK
huh? There is no way you can access Photoshop on a Client from an ASP.NET Web application.... this is completely incorrect.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!