Results 1 to 7 of 7

Thread: Set metadata for imageCapture of camera

  1. #1
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default 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).

    Qt Code:
    1. camera.imageCapture.setMetadata("Author", "Neda")
    2. camera.imageCapture.capture()
    To copy to clipboard, switch view to plain text mode 
    Last edited by neda; 3rd May 2016 at 07:27.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set metadata for imageCapture of camera

    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,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Set metadata for imageCapture of camera

    Quote Originally Posted by anda_skoa View Post
    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.
    Qt Code:
    1. Camera {
    2. id: camera
    3. metaData.author: "neda"
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set metadata for imageCapture of camera

    Quote Originally Posted by neda View Post
    No.
    Then metadata might not be supported.

    As you can see here, 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,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    neda (3rd May 2016)

  6. #5
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Set metadata for imageCapture of camera

    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.

    Qt Code:
    1. QImage image("c:/1.png");
    2. QImageWriter writer("c:/11.png", "png");
    3. writer.setText("Author", "neda");
    4. writer.write(image);
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. QImage image("c:/1.jpg");
    2. QImageWriter writer("c:/11.jpg", "jpg");
    3. writer.setText("Author", "neda");
    4. writer.write(image);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QImage image("c:/1.jpg");
    2. QImageWriter writer("c:/11.png", "png");
    3. writer.setText("Author", "neda");
    4. writer.write(image);
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Set metadata for imageCapture of camera

    Have you checked if the image writer for the given format supports that?
    See QImageWriter::supportsOption().

    Cheers,
    _

  8. The following user says thank you to anda_skoa for this useful post:

    neda (11th May 2016)

  9. #7
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Set metadata for imageCapture of camera

    Quote Originally Posted by anda_skoa View Post
    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).

    Qt Code:
    1. void ImageSaver::save(const QString &path) const
    2. {
    3. QImage image("c:/3.jpeg");
    4. QImageWriter writer("c:/3.jpg", "jpg");
    5. if (writer.supportsOption(QImageIOHandler::Description)) ==>true
    6. {
    7. writer.setText("Author", "John Smith"); ==>
    8. writer.write(image);
    9. }
    10. else
    11. img_.save(path);
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by neda; 11th May 2016 at 07:12.

Similar Threads

  1. Replies: 0
    Last Post: 1st July 2013, 08:59
  2. [QT5] QtMultimedia | i can`t get metadata
    By petrusPL in forum Newbie
    Replies: 0
    Last Post: 27th February 2013, 14:16
  3. Phonon handling mp3 metadata
    By Baasie in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2010, 20:52
  4. Inserting PDF metadata
    By Randria in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2009, 10:18
  5. Specifying method metadata
    By brcain in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 01:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.