Get the size of jpg file of QImage file before saving it.
Unsolved
General and Desktop
-
Hi,
I could get the target QImage from source QImage by the following snippet.
QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); QImageWriter writer; writer.setDevice(&buffer); writer.setFormat("jpg"); writer.setQuality(88); writer.write(image_source); image_target.loadFromData(ba);
Is there any way which tells me how much kilo byte this jpg file would take up even before I save it to disk?
I tried to use buffer.data.size(), but it seems give me the size before jpg compression. -
Hi,
No, because it depends on what your image contains.
By the way, why are you using such a complicated way to copy data from
image_source
toimage_target
?