How to resize jpg image through matlab to EXACT 300kb file size

1 view (last 30 days)
i have an image of 297kb but for some reasons i want it to be in exact 300kb for uploading else it will not be uploaded. how do i code from scratch from uploading pic to matlab to rsize it to 300 kb. please help urgent:)

Answers (2)

ahmed nebli
ahmed nebli on 1 Sep 2018
u can use the function imresize like this link https://www.mathworks.com/help/images/ref/imresize.html but u need to know how many rows and colums are in 300kb

Image Analyst
Image Analyst on 1 Sep 2018
Whether or not you can do this depends on the size of your image, how big the header info is, and if you're using compression or not. I'd recommend you NOT use compression, like used by JPG and PNG formats because those formats will give you variable sizes. You're better off using BMP or TIFF formats, but even then you'll have to figure out how big the header is. So use imresize() to shrink your image until it's just below 300,000 bytes, then you'll have to add some padding to some of the header tags to get it up to exactly 300,000 bytes.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!