View Full Version : Set metadata for imageCapture of camera
Hi,
I use Qt version 5.6.0 with qml from windows 8.1.
I want to set metadata for captured images in QML.
I've tried the following code, the program runs on desktop takes the picture and saves it.
After I open it up with Preview and check the metadata... and nothing special there (no Author key).
camera.imageCapture.setMetadata("Author", "Neda")
camera.imageCapture.capture()
anda_skoa
3rd May 2016, 09:00
The code for this is a bit complicated since this is plugin based, but maybe the service or the target format don't have meta data capabilities.
Do you get the imageMetaDataAvailable() signal?
Cheers,
_
The code for this is a bit complicated since this is plugin based, but maybe the service or the target format don't have meta data capabilities.
Do you get the imageMetaDataAvailable() signal?
Cheers,
_
No.
Also I used this code, but it does not work.
Camera {
id: camera
metaData.author: "neda"
anda_skoa
3rd May 2016, 09:41
No.
Then metadata might not be supported.
As you can see here (https://code.woboq.org/qt5/qtmultimedia/src/imports/multimedia/qdeclarativecameracapture.cpp.html#_ZN25QDeclarati veCameraCaptureC1EP7QCameraP7QObject), the metadata writer can be 0 and QDeclarativeCameraCapture::setMetadata() (same file) just forwards the values to that object if it is not 0.
You could run the application in the debugger, set a break point in setMetadata() and see if that is the case.
Cheers,
_
QImageWriter has a method for adding text to an image file:
http://doc.qt.io/qt-5/qimagewriter.html#setText
I've tried using QImageWriter::setText(const QString & key, const QString & text) for storing copyright information or other information about the image.
But It does not work.
QImage image("c:/1.png");
QImageWriter writer("c:/11.png", "png");
writer.setText("Author", "neda");
writer.write(image);
QImage image("c:/1.jpg");
QImageWriter writer("c:/11.jpg", "jpg");
writer.setText("Author", "neda");
writer.write(image);
QImage image("c:/1.jpg");
QImageWriter writer("c:/11.png", "png");
writer.setText("Author", "neda");
writer.write(image);
anda_skoa
10th May 2016, 07:28
Have you checked if the image writer for the given format supports that?
See QImageWriter::supportsOption().
Cheers,
_
Have you checked if the image writer for the given format supports that?
See QImageWriter::supportsOption().
_
This function returns true. But, none of my tries gave me any success (change data in Image Details tab properties).
void ImageSaver::save(const QString &path) const
{
QImage image("c:/3.jpeg");
QImageWriter writer("c:/3.jpg", "jpg");
if (writer.supportsOption(QImageIOHandler::Descriptio n)) ==>true
{
writer.setText("Author", "John Smith"); ==>
writer.write(image);
}
else
img_.save(path);
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.