Unsolved QImage setText and remove it
-
Hi,
We can create an image file with text by
QImage image("source.jpeg"); QImageWriter writer("target.jpeg"); writer.setText("Author", "John Smith"); writer.write(image);
After creating target.jpeg with the text, how can I remove the text from
target.jpeg? I did writer.setText("", ""); but it did not make any change.This process, file -> QImage -> file, resamples image so the size of file
changes (for example, source.jpge(200 Kb) -> target.jpeg(140 Kb)). Is there
any way I can just edit text of source.jpeg without resampling, so the size
of source.jpeg effectively remains the same? -
@samdol hi,friend,welcome.
It is Ok in my OS.
X:MacOS X$ file source.jpeg source.jpeg: JPEG image data, JFIF standard 1.01
writer.setText("Author", "John Smith");
X:MacOS X$ file target.jpeg target.jpeg: JPEG image data, JFIF standard 1.01, comment: "Author: John Smith??"
writer.setText("Author", "");
X:MacOS X$ file target_1.jpeg target_1.jpeg: JPEG image data, JFIF standard 1.01, comment: "Author: ??"
writer.setText("", "");
X:MacOS X$ file target_2.jpeg target_2.jpeg: JPEG image data, JFIF standard 1.01 X:MacOS X$ ll total 120 -rw-r--r--@ 1 X staff 3787 10 16 11:24 source.jpeg -rw-r--r-- 1 X staff 3683 10 16 11:27 target.jpeg -rw-r--r-- 1 X staff 3673 10 16 11:54 target_1.jpeg -rw-r--r-- 1 X staff 3661 10 16 11:56 target_2.jpeg
But, why the target_2 image size is smaller than source image.
-
@joeQ said in QImage setText and remove it:
But, why the target_2 image size is smaller than source image.
Because it contains less information I guess (no Author at all).
-
@joeQ
Thank you for testing on Mac OS. I don't know why, but I could not remove it on Windows. It is interesting you get the target file size which is about the same as source file size. Could you get the similar file size when you try jpg file of size ~ 10MByte?