This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, January 17, 2007 2:06:52 PM(UTC)
Groups: Registered
Posts: 4
I am new to Leadtools and I'm using version 9.0. I need to dynamically size JPG files below a 32K threshold. The images will vary in DPI and size. What is the best way to do this? I'm tried loading the image, grabbing some the BitmapYRes and have a DO CASE for multiple DPI but that seems very clunky. Is there a cleaner way?
Thanks
Gary
#2
Posted
:
Thursday, January 18, 2007 3:48:01 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Gary,
Do you want to reduce the image's width/height as well, or do you just want to reduce the file size?
#3
Posted
:
Thursday, January 18, 2007 5:21:11 AM(UTC)
Groups: Registered
Posts: 4
Bashar
My ultimate goal is to reduce the file size without negatively impacting image quality.
Thank you,
Gary
#4
Posted
:
Thursday, January 18, 2007 6:01:02 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
In this case, all you need to do is save it (using the Save method)
using a suitable compression. JPEG is the best balance between
high compression and good quality. However, the result you get
also depends highly on your image. For example, if your image is
already compressed, you may not be able to reduce its file size without
affecting quality.
I hope this helps.
#5
Posted
:
Thursday, January 18, 2007 6:50:25 AM(UTC)
Groups: Registered
Posts: 4
Bashar
I think you misunderstood me. Here is my challenge. I have a set of images that I need to go through each image and if its file size is greater than 32KB I need ti size the image to less than that without effecting image quality. I can reduce its size but how much should I reduce it by to get it under the 32KB limit?
Thank you,
Gary
#6
Posted
:
Friday, January 19, 2007 10:27:14 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
Like Bashar said, it depends on the image data. Two different uncompressed images that are 500KB will likely have different compressed file sizes even if you use the same compression algorithm and Quality Factor. There is no absolute algorithm and/or QFactor that will get all images below your 32KB limit.
You are going to have to test a large variety of images and see what compression type and quality factor give you acceptable results across the board. Either that, or you are going to have to do some kind of extra detection on the disk size of the images. For example, if the original size is only 50KB, you can afford a lower QFactor than something like a 500KB image. You should also check the original file format. An uncompressed JPEG that is 50KB can use a lower QFactor while a 50KB JPEG that's already compressed will need a higher one to make sure it's file size actually gets reduced.
For JPEG compression, 4:4:4 can give you lossless compression because it is not subsampling your pixels. If you use something like 4:2:2 or 4:1:1 you will get color loss, but the amount of compression will be much greater than 4:4:4. Additionally, you can increase your quality and file size with a lower QFactor or decrease your file size and image quality with a higher QFactor.
#7
Posted
:
Friday, January 19, 2007 2:01:23 PM(UTC)
Groups: Registered
Posts: 4
Thanks for your response.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.