473,799 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thumbnail Image Quality Issues

Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still
smaller then the original. I store these in SQL 2000 server.

The quality of the small thumbnail is ok, but the quality of the larger
image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

Is there any way to control the compression level of a Jpeg??

If any one can give me some suggestions I would greatly appreciate it.

Chris
Nov 18 '05 #1
6 2507
Some suggest converting your thumnails to png. This has worked best for me.
"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still
smaller then the original. I store these in SQL 2000 server.

The quality of the small thumbnail is ok, but the quality of the larger
image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

Is there any way to control the compression level of a Jpeg??

If any one can give me some suggestions I would greatly appreciate it.

Chris

Nov 18 '05 #2
Yes there is a Quality level for jpeg images. Start out simple and create
an application that takes an image, modifies it (height, width, quality)
then save it or stram it to the browser in different formats including the
original and see how it looks. If your images are photos then I would stick
with jpegs. I don't know what method/control you are using but this is a
good starting point.

"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still
smaller then the original. I store these in SQL 2000 server.
image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

The quality of the small thumbnail is ok, but the quality of the larger> Is there any way to control the compression level of a Jpeg??
If any one can give me some suggestions I would greatly appreciate it.

Chris

Nov 18 '05 #3
I have tried storing it in png with no visible improvement.

Is there maybe a specific way of converting it??

I don't think there is a problem with the GetThumbNail method as it returns
a good quality image if I get the image from the aspx page. the quality
worsens drastically when I write the image to a stream and to SQL server and
then retrieve it again.

Any ideas on that

Chris
"Manit Chanthavong" <ma***@chanthav ong.com> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
Some suggest converting your thumnails to png. This has worked best for me.

"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still
smaller then the original. I store these in SQL 2000 server.

The quality of the small thumbnail is ok, but the quality of the larger
image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

Is there any way to control the compression level of a Jpeg??

If any one can give me some suggestions I would greatly appreciate it.

Chris


Nov 18 '05 #4
It looks like you are using the image (GDI) class to do your conversions. I
don't think GetThumbNail by default does not do anything with the image
quality level. Hecnce you are seeing a decent image. What method are you
using to convert your other image? fyi, you can try the GetThumbNail and
specify a height and width for your second image if you really want.
Somethimes images have a thumbnails embeeded in the file in which
GetThumbNail returns that other wise GetThumbNail will just scale your image
to your specification (height, width). You will have to post code for me to
help you.

"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
I have tried storing it in png with no visible improvement.

Is there maybe a specific way of converting it??

I don't think there is a problem with the GetThumbNail method as it returns a good quality image if I get the image from the aspx page. the quality
worsens drastically when I write the image to a stream and to SQL server and then retrieve it again.

Any ideas on that

Chris
"Manit Chanthavong" <ma***@chanthav ong.com> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
Some suggest converting your thumnails to png. This has worked best for

me.


"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still smaller then the original. I store these in SQL 2000 server.

The quality of the small thumbnail is ok, but the quality of the larger image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

Is there any way to control the compression level of a Jpeg??

If any one can give me some suggestions I would greatly appreciate it.

Chris



Nov 18 '05 #5
Dan,

Here is the code I'm using to do this. Thanks in advance for taking a look
at this for me. I'm out of ideas.

'Declarations
Dim fsImageSize As Integer
Dim fsImageContent As Byte()
Dim fsImageType As String
Dim tnThumbnailSize As Integer
Dim tnThumbnailCont ent As Byte()
Dim tnThumbnailType As String
Dim orImage As System.Drawing. Image
Dim fsImage As System.Drawing. Image
Dim tnImage As System.Drawing. Image
Dim WHRatio As Single
Dim ms As New System.IO.Memor yStream()
Dim ms2 As New System.IO.Memor yStream()

'get image from submit and calculate WH ration
orImage = System.Drawing. Image.FromStrea m(Picture.Poste dFile.InputStre am)
WHRatio = orImage.Width / orImage.Height

'Resize image and create Thumbnail
fsImage = ResizeImage(orI mage, 500 / WHRatio, 500) '---- See below for the
resizeimage function
tnImage = ResizeImage(orI mage, 125 / WHRatio, 125) '---- See below for the
resizeimage function

'Convert both images to binary for save operation
fsImage.Save(ms , Imaging.ImageFo rmat.Bmp)
fsImageSize = ms.Length
ReDim fsImageContent( fsImageSize)
ms.Seek(0, IO.SeekOrigin.B egin)
ms.Read(fsImage Content, 0, fsImageContent. Length)

tnImage.Save(ms 2, Imaging.ImageFo rmat.Bmp)
tnThumbnailSize = ms2.Length
ReDim tnThumbnailCont ent(tnThumbnail Size)
ms2.Seek(0, IO.SeekOrigin.B egin)
ms2.Read(tnThum bnailContent, 0, tnThumbnailCont ent.Length)

Then I dump it to the DB via Stored Procedure:

..Parameters.Ad d("@ImageConten t", SqlDbType.Image ).Value = fsImageContent
..Parameters.Ad d("@ThumbnailCo ntent", SqlDbType.Image ).Value =
tnThumbnailCont ent

Resize Function:

Shared Function ResizeImage(ByV al p_objImage As System.Drawing. Image, ByVal
p_intHeight As Integer, ByVal p_intWidth As Integer) As System.Drawing. Image
Dim intHeight As Integer
Dim intWidth As Integer
intHeight = p_objImage.Heig ht
intWidth = p_objImage.Widt h
If p_intHeight > -1 And p_intWidth > -1 Then
intHeight = p_intHeight
intWidth = p_intWidth
ElseIf p_intHeight > -1 Then
If p_intWidth > -1 Then
intWidth = p_intWidth
Else
intWidth = CInt(intWidth / (intHeight / p_intHeight))
End If
intHeight = p_intHeight
End If
If p_intWidth > -1 Then
If p_intHeight > -1 Then
intHeight = p_intHeight
Else
intHeight = CInt(intHeight / (intWidth / p_intWidth))
End If
intWidth = p_intWidth
End If
Return p_objImage.GetT humbnailImage(i ntWidth, intHeight, Nothing, Nothing)
End Function

Thaks again ... Chris

"Dan Nigro" <dw*****@direcw ay.com> wrote in message
news:es******** ******@tk2msftn gp13.phx.gbl...
It looks like you are using the image (GDI) class to do your conversions. I don't think GetThumbNail by default does not do anything with the image
quality level. Hecnce you are seeing a decent image. What method are you
using to convert your other image? fyi, you can try the GetThumbNail and
specify a height and width for your second image if you really want.
Somethimes images have a thumbnails embeeded in the file in which
GetThumbNail returns that other wise GetThumbNail will just scale your image to your specification (height, width). You will have to post code for me to help you.

"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
I have tried storing it in png with no visible improvement.

Is there maybe a specific way of converting it??

I don't think there is a problem with the GetThumbNail method as it

returns
a good quality image if I get the image from the aspx page. the quality
worsens drastically when I write the image to a stream and to SQL server

and
then retrieve it again.

Any ideas on that

Chris
"Manit Chanthavong" <ma***@chanthav ong.com> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
Some suggest converting your thumnails to png. This has worked best for
me.


"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
> Hi,
>
> I have an application where a user uploads an image and I create two
> thumbnails. One a small image and the second is a larger image but still > smaller then the original. I store these in SQL 2000 server.
>
> The quality of the small thumbnail is ok, but the quality of the larger > image is terrible. I tried both Jpeg and Gif formats and there is no
> difference.
>
> Is there any way to control the compression level of a Jpeg??
>
> If any one can give me some suggestions I would greatly appreciate

it. >
> Chris
>
>



Nov 18 '05 #6
dwn
Here are some routines I just put together. Anything with "img..." is a
image parameter that you need to pass in. I am confused on your height to
width scaling but I think you have the right idea. Play around with that a
bit more but for now leave it out and try these routunies. I would not use
GetThumbnail for images bigger than 100x100.

Sub StreamImage(img Height as integer, imgWidth as integer, imgFileName as
String, imgQuality as integer)

Dim myNewImage As System.drawing. Image
Dim myImageCodecInf o As ImageCodecInfo
Dim myEncoder As Encoder
Dim myEncoderParame ter As EncoderParamete r
Dim myEncoderParame ters As EncoderParamete rs

Try
Select Case imgQuality

Case Is = 0

If imgWidth = 0 Then imgWidth = 200
If imgHeight = 0 Then imgHeight = 200
myNewImage = mgAdjustBitmap( imgFileName, imgWidth,
imgHeight)

myNewImage.Save (Response.Outpu tStream,
System.Drawing. Imaging.ImageFo rmat.Jpeg)

Case Else

If imgWidth = 0 Then imgWidth = 90
If imgHeight = 0 Then imgHeight = 90
myNewImage = mgGetThumbNail( imgFileName, imgWidth,
imgHeight)

'Image Type
'myImageCodecIn fo = GetEncoderInfo( "image/tiff")
myImageCodecInf o = GetEncoderInfo( "image/jpeg")

'Image Qualiy for Jpeg only
myEncoder = Encoder.Quality
myEncoderParame ters = New EncoderParamete rs(1)
'25L is the quality level Hard to 25 coded for now
'but I would use imgQuality to create the 25L for
example
myEncoderParame ter = New EncoderParamete r(myEncoder,
25L)
myEncoderParame ters.Param(0) = myEncoderParame ter

'myNewImage.Sav e(Response.Outp utStream,
ImageFormat.Jpe g)
myNewImage.Save (Response.Outpu tStream, myImageCodecInf o,
myEncoderParame ters)

End Select

Catch

End Try

End Sub

Function GetEncoderInfo( ByVal mimeType As String) As ImageCodecInfo

Dim J As Integer
Dim encoders As ImageCodecInfo( )
encoders = ImageCodecInfo. GetImageEncoder s()
For J = 0 To encoders.Length
If encoders(J).Mim eType = mimeType Then
GetEncoderInfo = encoders(J)
Exit For
End If
Next

End Function

Function mgGetThumbNail( ByVal strFile As String, ByVal intWidth As
Integer, ByVal intHeight As Integer) As System.drawing. Image

Dim myBitmap As Bitmap = New Bitmap(strFile)
Return myBitmap.GetThu mbnailImage(int Width, intHeight, Nothing,
Nothing)
myBitmap.Dispos e()

End Function

Function mgAdjustBitmap( ByVal strFile As String, ByVal intHorz As
Integer, ByVal intVert As Integer) As Bitmap

Dim mysize As Size
Dim myBitmap As Bitmap = New Bitmap(strFile)
If intHorz > 0 Then
mysize = New Size(intHorz, intVert)
Else
mysize = New Size(myBitmap.W idth, myBitmap.Height )
End If
Dim myImg As Bitmap = New Bitmap(myBitmap , mysize)
Return myImg
myBitmap.Dispos e()

End Function

"Chris D" <qw*****@hotmai l.com> wrote in message
news:3f******** @news.nucleus.c om...
Hi,

I have an application where a user uploads an image and I create two
thumbnails. One a small image and the second is a larger image but still
smaller then the original. I store these in SQL 2000 server.

The quality of the small thumbnail is ok, but the quality of the larger
image is terrible. I tried both Jpeg and Gif formats and there is no
difference.

Is there any way to control the compression level of a Jpeg??

If any one can give me some suggestions I would greatly appreciate it.

Chris

Nov 18 '05 #7

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

Similar topics

0
5614
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.
0
290
by: Chris D | last post by:
Hi, I have an application where a user uploads an image and I create two thumbnails. One a small image and the second is a larger image but still smaller then the original. I store these in SQL 2000 server. The quality of the small thumbnail is ok, but the quality of the larger image is terrible. I tried both Jpeg and Gif formats and there is no difference.
6
1745
by: Trint Smith | last post by:
How can I show image thumbnail?? thanks, Trint ..Net programmer trintsmith@hotmail.com *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
1359
by: moondaddy | last post by:
I have an app where users will upload photos to their shopping cart. When they review their cart I need to include a light weight thumbnail of the image they uploaded. how can I take the image a user uploaded (PixOfMom.jpg at 600k) and convert it to a thumbnail and put into the image url of a .net image control using vb.net 1.1? Thanks! -- moondaddy@nospam.com
1
1729
by: Cédric | last post by:
Hello, Wanting to create a thumbnail of an image, i'm using the following piece of code : Public Sub Reduction(ByVal Source As String, ByVal Destination As String, ByVal TailleX As String, ByVal TailleY As String, ByVal Resolution As Integer, ByVal Fond As Boolean, ByVal ConserverRatio As Boolean, ByVal PixelFormat As System.Drawing.Imaging.PixelFormat, ByVal ImageFormat As System.Drawing.Imaging.ImageFormat, ByVal R As Integer, ByVal...
1
4988
by: Summercoolness | last post by:
In PIL, since thumbnail() first makes a draft copy of the image, and then resize it, so thumbnail() can run a lot faster than resize() because draft() seems a lot faster when resizing from very big images to small images... (such as the original image is 3000 x 2000, and it can make a draft really quickly to 375 x 250, and then resize to, say 200 x 133 as a thumbnail) However, the double resizing probably will make a thumbnail with a...
0
2524
by: sakurasyi | last post by:
hai guys... can someone solve my problems? i'm doing a thumbnail program. But, i have some problems. 1. The thumbnail image become black (cannot see anything) 2. Can anyone know how to get the size (height and width) of the original image? this is my code: Image image = Toolkit.getDefaultToolkit().getImage(namePath); MediaTracker mediaTracker = new MediaTracker(new Container()); mediaTracker.addImage(image, 0);
8
20371
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
15
13329
tlhintoq
by: tlhintoq | last post by:
I'd like to think I can work out most issues, but this one is kicking my butt. What's worse, is that I know I can't be the first guy to want to add a thumbnail to jpg that doesn't already have one. I see it in plenty of other applications. Yet I can't seem to make it work despite being so very close. I know the problem has to be in how I am making the PropertyItem of the thumbnail - because if I comment out lines 24-34 the JPG saves fine,...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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
10485
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...
0
10252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
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,...
0
5463
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
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.