-
Thumb preview
Allright, I have a directory in my web project that has a whole bunch of pictures. They are quite large. The pictures are of products the site will be selling, so I will need a large view of the picture if a customer decides to click on it.
Problem is, if I use the current pictures, which are 100k each (200x200), for my main product display, thesite loads slow. Since even if i make the <IMG WIDTH and LENGTH> small, the site still loads the entire picture.
So.. is there a way to generate a preview picture first from the original? Right now its not possible to take every picture into photoshop and downsize them and shrink them and upload them again.. and etc etc...
I will need to use the originals. Any idea?
-
How ever you do it, its not gonna be easy.
You could probably download component to generate thumbnail on the fly, but that will be slow if you have quite a lot of images.
My suggestion would be to use a batch converter and resize them to a smaller size. This will be much efficient then any other ways.
Hope it helps.
Danial
-
ugh.. and just when i thought it was gonna be going downhill :)
Thanks for the reply D,
Batch convertor? I never used anything like this, mind explainig in more detail?
Also, the pictures are still being uploaded through ASP Upload. I would like the new ones that are being uploaded also shrunk down. So if there is a way where the upladed image can be split into two images (image1 and image1small) that would be great.
I don't think ASP upload has any of those options. Jodohosthas a component called ASP Image.. any ideas on what that is?
I'll do my research when I get home tonight, no time at work.
Thanks Danial
-
For the benfit of people reading this thread you could achieve what Invitro wanted using combination of two component from Persist(Both free) called AspUpload and AspJpeg.
I knew about AspUpload but didnt know AspJpeg existed until i spoke to Invitro, so thank him if it came to any use for you.
Here is the link http://www.aspupload.com/
-
Re: Thumb preview
I had the same problem and solved it with the help of this tutorial, plus i modified the image grabber routine from the tutorial, so it looks like this:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim ds As New Data.DataSet
Dim da As New SqlDataAdapter
Dim arrContent, slika As Byte()
Dim dr As Data.DataRow
Dim pic, thumb As System.Drawing.Image
Dim width, height, size As Integer
Dim SQL As String = "select * from imgs where imgId=" & Request.QueryString("ID")
Dim connString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=""|DataDirectory|\imgDB.mdf"";Integrated Security=True;User Instance=True"
da = New SqlDataAdapter(SQL, connString)
da.Fill(ds)
dr = ds.Tables(0).Rows(0)
arrContent = CType(dr.Item("imgData"), Byte())
Dim conType As String = dr.Item("imgType").ToString
'making the thumbnail
Dim stream As New System.IO.MemoryStream(arrContent)
pic = System.Drawing.Image.FromStream(stream)
width = 100
height = pic.Height / (pic.Width / 100)
thumb = pic.GetThumbnailImage(width, height, Nothing, System.IntPtr.Zero)
stream.Dispose()
pic.Dispose()
Using str As New System.IO.MemoryStream
thumb.Save(str, System.Drawing.Imaging.ImageFormat.Jpeg)
slika = str.GetBuffer
size = str.Length
End Using
thumb.Dispose()
Response.ContentType = conType
Response.OutputStream.Write(slika, 0, size)
Response.End()
Catch ex As Exception
End Try
End Sub
hope it helps