-
Image Compressing
I'm working on a project which requires me store images from image control / picture box as a physical file. I've tried using SavePicture Command, but it stores only in BMP format which takes up a lot of space.
I would like to store it in a compressed format, so that the image occupies minimal amount of space say below 1KB.
Anybody who can help me out regarding this
-
what format would you like to compress it in, i happen to have source for jpeg compression
-
Any type of format is OK for me even JPG as long as it offers the level of compression I need, ie., some where below 1KB
-
depends, compression level is defined as a ratio of the outcome data by the original. JPEG reduces the quality until a specified ratio is obtained
-
can u send me the jpeg source u have
-
yeah i could if you give me your email ad
-
-
----- The following addresses had permanent fatal errors -----
<mailto:[email protected]>
(reason: 550 Invalid recipient: <"mailto:pavan_crm"@excite.com>)
-
I could not get ur mail. Pls. mail me again
My email ID : Pavan ([email protected])
-
Over here too please:P
Lo Kedaman
can you also send me the source please
[email protected]
thank you
-
-
sorry but I didnt catch ur meanining in N/P
-
no problem.
btw, i'm had problem sending the mail, but now it succeeded, did you recieve it?
-
Thanx for ur reply. I think i got ur mail but i'm unable to view my inbox due to bad NET connection I'll try it again and let u know of it
-
Thanx
Thanks Kedaman. I've got ur mail and have downloded it. I'm right now goin thru it and I find it very usefule.
Thanks again.
-
Query
Hi kedaman
I've gone thru ur code. Its compression capability is good. But I want to know how to restore the original image, after compressing it, with the same quality.
Thanx in Advance.
-
You can't, you need to use other graphics formats...
I've created my own with a little compression, you can find it here: http://psprogramming.virtualave.net/...7/dd/zlib.html
-
Me too!
Hi kedaman,
Could you send me the code too.
[email protected]
Thanks in advance.
Sean. :D
-
Fleming: Sure.
pavan: A quality reducing format like jpeg looses quality every time you compress it, there's no way to restore it. Gif compression doesn't reduce the size as much as jpeg but keeps the quality, although with a max 256 color palette.
-
Hey Kedaman, can you send it to me (sorry I'm late) please?
[email protected]
BTW, the comma or fullstop in your signiture, is that your site? And howcome I'm not welcome? No, what I mean to have said is who is welcome?
-
ok sent, yeah it's my homepage, and youre welcome to the site, if you check it out
-
hi
Hi psychomark,
I've seen ur page and also downloaded the dlls. but the problem is they work only with BMPs whereas i need the compression utility for JPGs or GIFs which originally occupy a very little space.
-
Hi kedaman,
If you have already sent me the file, or even if you haven't, could you please resend it to:
[email protected]
another.com is way too slow, it takes ages for anything to get through.
Fleming.
-
PNG format is compressed, and it isn't lossy. Maybe you could find some source for that somewhere.
-
The reason I used BMP's for the compression, is that I can draw them using the raw byte data, whereas JPG's and GIF's would require you to unpack the file to disk first, then load it (using for example LoadPicture). If you don't mind temporary files, you can just compress and uncompress the pictures using the zLib.dll...
-
Thanx
Thanx Psychomark for giving me the advice I will try ur advice.
-
Hi
Hi PsychoMark,
I've tried compressing and decompressing of JPGs with zlib.dll as u suggested.
But while compressing the compresion ratio seems to be very little / negligble for JPGs. the compressed file was only a few bytes smaller than the original file.
And while decompressing it, I repeatedly got an error saying 'out of stack space'.
can u help me out of it.
Thanx in Advance
-
1. The low compression ratios are not that strange, since JPG's are already compressed. For example, use WinZip to compress a Bitmap and a JPG in the same way, you'll notice that the JPG isn't compressed as much as the BMP.
2. Can't do anything without code, so if you still want to compress JPGs, send the code which you used to compress it, and mark the line where the error occurs...
-
Reply
Hi Psychomark,
I haven't changed much the code i've downloaded. I'm getting any error at clsBitmap.cls file. Anyway I'm sending it to u as attached Zipped file
-
Code:
' Create a bitmap out of the Byte array
cBitmap.ReadFromByteArray bData()
This is not possible, since we're reading JPG's. Comment the line out, and do the same for these:
Code:
cBitmap.ResizePicturebox picImage
cBitmap.BlitToDC picImage.hDC
picImage.Refresh
Haven't tested it, but it should work. The errors are occuring because you're trying to read the bitmap format from a JPG, which could cause VB to crash...
-
Hi,
I've tried all the advices given to me but the compressed file size seems to be a min. of 1.3KB max. its not going down further. i require the compressed image to be less than 1 KB. I've also tried reading the image pixel by pixel and storing it in the file with all the common colors codified ( an idea from vbsquare.com) but even then it has come to 1.2KB. so if anybody out ther can tell me how to achieve this i'll be thankful
Thnx in advance
-
Can you give me the image you want to compress? If so, I can check some other possibilities...
-
hi
Hi PsychoMark
The image i want to compress is not specific. It ithe photograph of a person. U can take any photograph of a person and then try out the possibilities.
-
Ic, well, let me know the average dimensions then, since the file size can vary a lot depending on the dimensions...
-
Dimensions
Hi
I've a requirement of Image dimensions are as follows.
The dimensions for one image are 19.05 x 25.4 mm / 0.75 x 1.0 inch
the dimensions for the other are 25.4 x 6.35 mm / 1.0 x 0.25 inch
all the dimensions are Width x Height