473,804 Members | 4,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="te xt/html" ResponseEncodin g="iso-8859-1"
%>
<%@ Import Namespace="Syst em.Drawing.Imag ing"%>
<%@ Import Namespace="Syst em.Drawing.imag e"%>
<script language="VB" runat="server">
Function ThumbnailCallba ck() as Boolean
return False
end function
Sub Page_Load()
Dim imageurl as string=Request. QueryString("im g")
imageurl="/images/" & imageurl
Dim fullsizeimg as system.Drawing. Image
fullsizeimg=Sys tem.Drawing.Ima ge.FromFile(Ser ver.M apPath("mug.gif "))
Response.Conten tType="image/gif"
'fullsizeimg.sa ve(Response.out putstream,image forma t.gif)
Dim dummyCallBack as System.Drawing. Image.GetThumbn ailImageAbort
dummyCallBack=N ew system.drawing. image.GetThumbn ailimageabort(A ddres sOf
ThumbnailCallba ck)
Dim thumbnailimg as System.Drawing. Image
thumbnailimg=fu llsizeimg.Getth umbnailImage(10 0,100 ,dummyCallBack, IntPtr.Zero)
thumbnailimg.Sa ve(Application. StartupPath&cst rThumbFileName)
End Sub
</script>

pls review it and tell me about he function thanks
Nov 19 '05 #1
2 1928
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.FileS tream fs = new System.IO.FileS tream(pathToFul lSizeImage,
System.IO.FileM ode.Open, System.IO.FileA ccess.Read);

System.Drawing. Image objThumbnail =
System.Drawing. Image.FromStrea m(fs).GetThumbn ailImage(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).Ge tThumbnailImage (iWidth,
iHeight, null, IntPtr.Zero);

// Set the ContentType correctly
if (fileType == "JPG" || fileType == "JPEG") {
objThumbnail.Sa ve(pathToThumbn ailImage, ImageFormat.Jpe g);
}
else {
objThumbnail.Sa ve(pathToThumbn ailImage, ImageFormat.Gif );
}
HTH
"asad" <as**@discussio ns.microsoft.co m> wrote in message
news:56******** *************** ***********@mic rosoft.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="te xt/html"
ResponseEncodin g="iso-8859-1"
%>
<%@ Import Namespace="Syst em.Drawing.Imag ing"%>
<%@ Import Namespace="Syst em.Drawing.imag e"%>
<script language="VB" runat="server">
Function ThumbnailCallba ck() as Boolean
return False
end function
Sub Page_Load()
Dim imageurl as string=Request. QueryString("im g")
imageurl="/images/" & imageurl
Dim fullsizeimg as system.Drawing. Image
fullsizeimg=Sys tem.Drawing.Ima ge.FromFile(Ser ver.M apPath("mug.gif "))
Response.Conten tType="image/gif"
'fullsizeimg.sa ve(Response.out putstream,image forma t.gif)
Dim dummyCallBack as System.Drawing. Image.GetThumbn ailImageAbort
dummyCallBack=N ew system.drawing. image.GetThumbn ailimageabort(A ddres sOf
ThumbnailCallba ck)
Dim thumbnailimg as System.Drawing. Image
thumbnailimg=fu llsizeimg.Getth umbnailImage(10 0,100
,dummyCallBack, IntPtr.Zero)
thumbnailimg.Sa ve(Application. StartupPath&cst rThumbFileName)
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="te xt/html"
ResponseEncodin g="iso-8859-1"
%>
<%@ Import Namespace="Syst em.Drawing.Imag ing"%>
<%@ Import Namespace="Syst em.Drawing.imag e"%>
<script language="VB" runat="server">
Function ThumbnailCallba ck() as Boolean
return False
end function
Sub Page_Load()
Dim imageurl as string=Request. QueryString("im g")
imageurl="/images/" & imageurl
Dim fullsizeimg as system.Drawing. Image
fullsizeimg=Sys tem.Drawing.Ima ge.FromFile(Ser ver.M apPath("mug.gif "))
Response.Conten tType="image/gif"
'fullsizeimg.sa ve(Response.out putstream,image forma t.gif)
Dim dummyCallBack as System.Drawing. Image.GetThumbn ailImageAbort
dummyCallBack=N ew system.drawing. image.GetThumbn ailimageabort(A ddres
sOf
ThumbnailCallba ck)
Dim thumbnailimg as System.Drawing. Image
thumbnailimg=fu llsizeimg.Getth umbnailImage(10 0,100
,dummyCallBack, IntPtr.Zero)
thumbnailimg.Sa ve(Application. StartupPath&cst rThumbFileName)
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
3215
by: Phil Powell | last post by:
$mogResponse = exec("mogrify -size ${width}x$height " . $this->locationPath . '/' . $this->fileName . ' -resize ' . $width . "x$height > +profile " . $this->thumbLocationPath . '/' . $this->fileName .. ' 2>&1'); This attempt at creating a thumbnail only causes the original image to be resized while creating a "ghost image" in the /thumb folder where
0
5617
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 documents. Thumbnail previews are useful for web site navigation particularly in search engines and directories such as Google, Altavista and Yahoo. The preview images provide a portion of the content of the electronic file to aid in navigation.
1
1501
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 use to create the thumbnail image...... *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
0
2296
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 this regard. It is a serious problem for me. Thanks! Approach - I - Bitmap (screen capture method) ============================================= Can able to create the thumbnail image using Bitmap and BitBlt.
3
1402
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 save it I get a "general error in GDI+". Can anyone tell me how to achieve this? Thanks
10
2042
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 fine for .jpg images but for some reason it doesn't work with .gif images. The author of the article says it works fine for him but I can't get it to work. I was wondering if anyone here can shed some light?
1
3243
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 gallery. ( http://xahlee.org/Periodic_dosage_dir/lanci/lanci.html ) Comments and versions in other lang welcome. Xah
7
17060
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 = "photo/thumbs/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images
2
1552
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 System.EventArgs) Handles CmbPath.SelectedIndexChanged Dim Table As DataTable Dim i As Integer Dim ThumbSize As Integer = 160
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.