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

1 vue (au cours des 30 derniers jours)
hadiqa khan
hadiqa khan le 1 Sep 2018
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:)

Réponses (2)

ahmed nebli
ahmed nebli le 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 le 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.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by