Thumbnail convert
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure;
using DataBlobStorage;
namespace KenCommerceWeb.Admin
{
public partial class Thumb : System.Web.UI.Page
{
BlobService bs = new BlobService();
protected void Page_Load(object sender, EventArgs e)
{
}
public static CloudStorageAccount GetConnectionString()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
return storageAccount;
}
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(MapPath("~/Uc/" + FileUpload1.FileName));
System.Drawing.Image img1 = System.Drawing.Image.FromFile(MapPath("~/Uc/") + FileUpload1.FileName);
System.Drawing.Image bmp1 = img1.GetThumbnailImage(50, 50, null, IntPtr.Zero);
bmp1.Save(MapPath("~/Thum/Thuml/") + FileUpload1.FileName);
System.Drawing.Image bmp2 = img1.GetThumbnailImage(100, 100, null, IntPtr.Zero);
bmp2.Save(MapPath("~/Thum/Thums/") + FileUpload1.FileName);
NormalImage.ImageUrl = "~/Uc/" + FileUpload1.FileName;
ThumbnailImageS.ImageUrl = "~/Thum/Thuml/" + FileUpload1.FileName;
ThumbnailImageM.ImageUrl = "~/Thum/Thums/" + FileUpload1.FileName;
}
}
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Admin.master" AutoEventWireup="true" CodeBehind="Thumb.aspx.cs" Inherits="KenCommerceWeb.Admin.Thumb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<asp:Label ID="labelMessage" runat="server" Text="Browse Image:" ForeColor="navy" Width="220"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<%--<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"></telerik:RadAsyncUpload>--%>
<asp:Button ID="Upload" runat="server" Text="Upload" OnClick="Upload_Click" />
</div>
<div>
<asp:Label ID="label1" runat="server" Text="Normal Image (Full size): " ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="NormalImage" runat="server" />
</div>
<div>
<asp:Label ID="label2" runat="server" Text="Thumbnail Small Image (50x50)px: " ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="ThumbnailImageS" runat="server" />
</div>
<div>
<asp:Label ID="label3" runat="server" Text="Thumbnail Large Image (100x100)px: "
ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="ThumbnailImageM" runat="server" />
</div>
</asp:Content>
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure;
using DataBlobStorage;
namespace KenCommerceWeb.Admin
{
public partial class Thumb : System.Web.UI.Page
{
BlobService bs = new BlobService();
protected void Page_Load(object sender, EventArgs e)
{
}
public static CloudStorageAccount GetConnectionString()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
return storageAccount;
}
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(MapPath("~/Uc/" + FileUpload1.FileName));
System.Drawing.Image img1 = System.Drawing.Image.FromFile(MapPath("~/Uc/") + FileUpload1.FileName);
System.Drawing.Image bmp1 = img1.GetThumbnailImage(50, 50, null, IntPtr.Zero);
bmp1.Save(MapPath("~/Thum/Thuml/") + FileUpload1.FileName);
System.Drawing.Image bmp2 = img1.GetThumbnailImage(100, 100, null, IntPtr.Zero);
bmp2.Save(MapPath("~/Thum/Thums/") + FileUpload1.FileName);
NormalImage.ImageUrl = "~/Uc/" + FileUpload1.FileName;
ThumbnailImageS.ImageUrl = "~/Thum/Thuml/" + FileUpload1.FileName;
ThumbnailImageM.ImageUrl = "~/Thum/Thums/" + FileUpload1.FileName;
}
}
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Admin.master" AutoEventWireup="true" CodeBehind="Thumb.aspx.cs" Inherits="KenCommerceWeb.Admin.Thumb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<asp:Label ID="labelMessage" runat="server" Text="Browse Image:" ForeColor="navy" Width="220"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<%--<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"></telerik:RadAsyncUpload>--%>
<asp:Button ID="Upload" runat="server" Text="Upload" OnClick="Upload_Click" />
</div>
<div>
<asp:Label ID="label1" runat="server" Text="Normal Image (Full size): " ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="NormalImage" runat="server" />
</div>
<div>
<asp:Label ID="label2" runat="server" Text="Thumbnail Small Image (50x50)px: " ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="ThumbnailImageS" runat="server" />
</div>
<div>
<asp:Label ID="label3" runat="server" Text="Thumbnail Large Image (100x100)px: "
ForeColor="navy" Width="220"></asp:Label>
<asp:Image ID="ThumbnailImageM" runat="server" />
</div>
</asp:Content>
Comments
Post a Comment