I don’t want the file size to change, i ve tried values from 0 to 1 but there is always a change in size, is there anyway i can maintain the same size, if i dont modify the image
I don’t think you can do that. The jpeg filter, which does a lossy conversion, is applied every time you save ther image, adding a little bit of quality loss to the output. Even if the file size increases, I think you loose some information.
You can’t expect to decompress and recompress using a lossy codec without changing the file size! It’s just not possible!
It might be possible to read a quality level from a jpeg file, and use that as the level at which you re-save it, but I’ve not written anything to do so. Any jpeg experts know if the format contains something like that? Still wouldn’t be the same size, of course, but it’ll be close.
Or, if you’re not going for speed, a quick hack would be to just repeatedly try saving with different quality settings, and see what size they produce - then you could home in on the value that produces the nearest size to the original. I’d have thought that within 3-4 attempts a binary chop search would get pretty close.