Board index » Web Programming » ASP.NET thumbnail creating and saving

ASP.NET thumbnail creating and saving

Web Programming147
Hello friends, how ru all, i have some problem about saving created

thumbnail, following is the code i use for creating thumbnail but thumbnail

was not saved it is on memory which method is used to store created thumbnail

in to hard disk







<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"

%>

<%@ Import Namespace="System.Drawing.Imaging"%>

<%@ Import Namespace="System.Drawing.image"%>

<script language="VB" runat="server">

Function ThumbnailCallback() as Boolean

return False

end function

Sub Page_Load()

Dim imageurl as string=Request.QueryString("img")

imageurl="/images/" & imageurl

Dim fullsizeimg as system.Drawing.Image

fullsizeimg=System.Drawing.Image.FromFile(Server.M apPath("mug.gif"))

Response.ContentType="image/gif"

'fullsizeimg.save(Response.outputstream,imageforma t.gif)

Dim dummyCallBack as System.Drawing.Image.GetThumbnailImageAbort

dummyCallBack=New system.drawing.image.GetThumbnailimageabort(Addres sOf

ThumbnailCallback)

Dim thumbnailimg as System.Drawing.Image

thumbnailimg=fullsizeimg.GetthumbnailImage(100,100 ,dummyCallBack,IntPtr.Zero)

thumbnailimg.Save(Application.StartupPath&cstrThumbFileName)

End Sub

</script>



pls review it and tell me about he function thanks


-
 

Re:ASP.NET thumbnail creating and saving

This works for me. It's C#, but all you need to do is pay attention to the

.NET Framework classes I'm using.



System.IO.FileStream fs = new System.IO.FileStream(pathToFullSizeImage,

System.IO.FileMode.Open, System.IO.FileAccess.Read);



System.Drawing.Image objThumbnail =

System.Drawing.Image.FromStream(fs).GetThumbnailImage(tWidth, tHeight, null,

IntPtr.Zero);



// DO NOT USE THE FOLLOWING LINE; Image.FromFile() keeps the file open. This

is why we open the file via a stream - a stream can be closed.

// System.Drawing.Image objThumbnail =

System.Drawing.Image.FromFile(strFilename).GetThumbnailImage(iWidth,

iHeight, null, IntPtr.Zero);



// Set the ContentType correctly

if (fileType == "JPG" || fileType == "JPEG") {

objThumbnail.Save(pathToThumbnailImage, ImageFormat.Jpeg);

}

else {

objThumbnail.Save(pathToThumbnailImage, ImageFormat.Gif);

}





HTH





"asad" <asad@discussions.microsoft.com>wrote in message

Quote
Hello friends, how ru all, i have some problem about saving created

thumbnail, following is the code i use for creating thumbnail but

thumbnail

was not saved it is on memory which method is used to store created

thumbnail

in to hard disk







<%@ Page Language="VB" ContentType="text/html"

ResponseEncoding="iso-8859-1"

%>

<%@ Import Namespace="System.Drawing.Imaging"%>

<%@ Import Namespace="System.Drawing.image"%>

<script language="VB" runat="server">

Function ThumbnailCallback() as Boolean

return False

end function

Sub Page_Load()

Dim imageurl as string=Request.QueryString("img")

imageurl="/images/" & imageurl

Dim fullsizeimg as system.Drawing.Image

fullsizeimg=System.Drawing.Image.FromFile(Server.M apPath("mug.gif"))

Response.ContentType="image/gif"

'fullsizeimg.save(Response.outputstream,imageforma t.gif)

Dim dummyCallBack as System.Drawing.Image.GetThumbnailImageAbort

dummyCallBack=New system.drawing.image.GetThumbnailimageabort(Addres sOf

ThumbnailCallback)

Dim thumbnailimg as System.Drawing.Image

thumbnailimg=fullsizeimg.GetthumbnailImage(100,100

,dummyCallBack,IntPtr.Zero)

thumbnailimg.Save(Application.StartupPath&cstrThumbFileName)

End Sub

</script>



pls review it and tell me about he function thanks









-

Re:ASP.NET thumbnail creating and saving

Don't forget to call Dispose on your Image objects (both the one you load

and the generated thumbnail one).

I have an implementation of this already here:



http://staff.develop.com/ballen/blog/PermaLink.aspx?guid" rel="nofollow" target="_blank">staff.develop.com/ballen/blog/PermaLink.aspx=2d8b430b-8361-416d-9df8-9aff48bf2481



-Brock

DevelopMentor

staff.develop.com/ballen">staff.develop.com/ballen







Quote
Hello friends, how ru all, i have some problem about saving created

thumbnail, following is the code i use for creating thumbnail but

thumbnail was not saved it is on memory which method is used to store

created thumbnail in to hard disk



<%@ Page Language="VB" ContentType="text/html"

ResponseEncoding="iso-8859-1"

%>

<%@ Import Namespace="System.Drawing.Imaging"%>

<%@ Import Namespace="System.Drawing.image"%>

<script language="VB" runat="server">

Function ThumbnailCallback() as Boolean

return False

end function

Sub Page_Load()

Dim imageurl as string=Request.QueryString("img")

imageurl="/images/" & imageurl

Dim fullsizeimg as system.Drawing.Image

fullsizeimg=System.Drawing.Image.FromFile(Server.M apPath("mug.gif"))

Response.ContentType="image/gif"

'fullsizeimg.save(Response.outputstream,imageforma t.gif)

Dim dummyCallBack as System.Drawing.Image.GetThumbnailImageAbort

dummyCallBack=New system.drawing.image.GetThumbnailimageabort(Addres

sOf

ThumbnailCallback)

Dim thumbnailimg as System.Drawing.Image

thumbnailimg=fullsizeimg.GetthumbnailImage(100,100

,dummyCallBack,IntPtr.Zero)

thumbnailimg.Save(Application.StartupPath&cstrThumbFileName)

End Sub

</script>

pls review it and tell me about he function thanks









-