#1
Posted
:
Monday, August 21, 2017 6:55:01 AM(UTC)
Groups: Registered
Posts: 1
Hello,
Is there any way to shrink/compress the physical size of an image (ex. from 8MB) to another given size (ex. to 4MB) without changing the resolution?
I tried using ChangeCompression but that changes the size only twice, after that the size is not affected anymore.
I would need a method that also accepts as parameter the size I need to get to OR a loop where I call a method that shrinks the size until it reaches the required one.
I am using Version 19.
Thank you!
#2
Posted
:
Tuesday, August 22, 2017 8:41:06 AM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Hello,
We had a live chat session to discuss this, so I will post a short summary here.
The ChangeCompression() method only affects the image data while it's in memory. In memory, the image can be uncompressed, run-length encoded, or use a LEAD proprietary compression. When the image is written to disk though, the image data in memory would have to be uncompressed first (if it isn't already) and then re-compressed before (or as) being written to disk. So the ChangeCompression() method I don't think is going to help you based on your question here.
There are two things that affect image compression:
1.) Physical size (height/width) of the image
2.) Compression used
Since changing the physical size is out, that leaves you with just changing the compression. You could technically change the bit depth of an image to reduce the output file size. This could work in cases where the original image is say 32-bit and you write out a 24-bit file. If that doesn't change the image quality and it's not data that you need, it could be a significant savings writing 25% less data for each pixel.
Some compressions do provide options that let you control the amount of compression being applied. For example, JPEG and PNG both have quality factor properties with their save options you can try. Check out
CodecsJpegSaveOptions.QualityFactor and
CodecsPngSaveOption.QualityFactor.
Pro-tip: The amount of compression you use is inversely proportional to the image quality. Generally the more you compress the image, the lower the image quality will be. The measure of an image compression is how much quality is retained versus the amount of compression it can apply.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Tuesday, January 2, 2024 7:43:27 AM(UTC)
Groups: Registered
Posts: 12
Thanks: 4 times
Originally Posted by: Cory Hello,
Is there any way to shrink/compress the physical size of an image (ex. from 8MB) to another given size (ex. to 4MB) without changing the resolution?
I tried using ChangeCompression but that changes the size only twice, after that the size is not affected anymore.
I would need a method that also accepts as parameter the size I need to get to OR a loop where I call a method that shrinks the size until it reaches the required one.
I am using Version 19.
Thank you!
Hi Cory
ChangeCompression() impacts image data in memory, not directly the disk physical size. Since resizing isn't an option, consider altering compression. Adjusting bit depth could reduce file size without compromising quality. Formats like JPEG and PNG offer settings like CodecsJpegSaveOptions.QualityFactor, allowing control over compression during saving. Remember increased compression often means reduced image quality. For precise needs and find the right balance between compression and image fidelity. For more information you can explore
Leadtools official doc.
Still you have any query then please let me know.
Thank you.
Edited by moderator Thursday, January 11, 2024 8:41:25 AM(UTC)
| Reason: Not specified
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.