PDA

View Full Version : QImagerWriter::setText and QImageReader::text() -- Do they work in 4.8 using a jpeg?



davethomaspilot
24th August 2015, 22:16
QImageWriter has a method for adding text to an image file:

http://doc.qt.io/qt-4.8/qimagewriter.html#setText

And QImageReader has a method to read the text, given a key and another method to print all the key names:

http://doc.qt.io/qt-4.8/qimagereader.html#text

I've tried using QImageWriter::setText(const QString & key, const QString & text) both with a key string and using and empty string for the key. No error results, but when I use QImageReader to read the text I get and empty string. When I use QImageReader::textKeys() I get "()".

Do these work for writing/reading text to a jpeg file? I'm assuming the text goes in the file header?

If so, is there a "trick" to get it to work?

Thanks.

wysota
25th August 2015, 07:49
I don't think you can store custom textual data in a jpeg. Try the same with PNG and see if it works.

anda_skoa
25th August 2015, 08:03
Maybe you can find the QImageIOHandler for the format somehow, it could then be asked if it supports the Description option:
http://doc.qt.io/qt-4.8/qimageiohandler.html#supportsOption

Cheers,
_

davethomaspilot
26th August 2015, 11:44
I don't think you can store custom textual data in a jpeg. Try the same with PNG and see if it works.

Ok, out of town and can't get to it until late this week. I'll give it a try then

davethomaspilot
31st August 2015, 20:38
Yes, it works fine with .png.

Is there a list somewhere that documents what image file formats work with the QImageWriter::text()? Is it just .png?