473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

ASP.NET thumbnail creating and saving

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&cstrThum bFileName)
End Sub
</script>

pls review it and tell me about he function thanks
Nov 19 '05 #1
2 1904
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).GetThumbnailIm age(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).GetThum bnailImage(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" <as**@discussions.microsoft.com> wrote in message
news:56**********************************@microsof t.com...
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&cstrThum bFileName)
End Sub
</script>

pls review it and tell me about he function thanks

Nov 19 '05 #2
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...8-9aff48bf2481

-Brock
DevelopMentor
http://staff.develop.com/ballen
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&cstrThum bFileName)
End Sub
</script>
pls review it and tell me about he function thanks


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Powell | last post by:
$mogResponse = exec("mogrify -size ${width}x$height " . $this->locationPath . '/' . $this->fileName . ' -resize ' . $width . "x$height > +profile " . $this->thumbLocationPath . '/' ....
0
by: Mike | last post by:
Sites using thumbnail preview for world wide web file navigation and searching. Below are list of sites that are either researching or providing thumbnail preview images for online web...
1
by: James Dean | last post by:
I have thought about creating a thumbnail from my full image but its too slow. What is the best algorithm to use for creating a thumbnail directly from data by yourself. What algorithm do microsoft...
0
by: Balu Ramachandran | last post by:
How can I create the Thumbnail view from the form? In the following approach I tried but Iams facing some limitations to get the thumbnail image of the form alone. Plaese any one can help in...
3
by: Peter Morris [Droopy Eyes Software] | last post by:
Hi all I have a JPG that has just been uploaded, and I now need to create a thumbnail. I loaded the JPG using Image.Load and created a new image using original.GetThumbnailImage, but when I...
10
by: David | last post by:
Greetings all, I am having a problem with an asp.net application using C# which is a thumbnail generator. Here is the code used... http://www.eggheadcafe.com/articles/20030515.asp It works...
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project...
7
by: mishrarajesh44 | last post by:
hii all Truly telling i hav got this code from net & i am finding error while running the code below.. code:- <?php $idir = "photo/"; // Path To Images Directory $tdir =...
2
by: djpaul | last post by:
Hello, I have this program and when i want to load pictures it crashes at the form.showdialog()....??? Here it goes: Private Sub CmbPath_SelectedIndexChanged(ByVal sender As Object, ByVal e As...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.