Results 1 to 9 of 9

Thread: scanning images

  1. #1
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation scanning images

    hi,

    I am relatively new to QT, I am developing a photo management application in which i need to
    scan all the images in the filesystem(i'm using fedora core) . Along with QFileinfo and QDirIterator, I need a function which reads a file and determines whether it is an image(irrespective of the extension)...can QImageReader.canRead() do the job?It should also deal with the case where we rename a text file into an image.

    Also I wish to know if we can use exif information of an image through qt

    i tried using canRead function on a jpeg file(a true image) and it returned false when i used the error() function it showed devise error. wat might be wrong?

    any help would be appreciated

    thankyou

    srihari

  2. The following user says thank you to sriluyarlagadda for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: scanning images

    Quote Originally Posted by sriluyarlagadda View Post
    can QImageReader.canRead() do the job?
    Yes.

    It should also deal with the case where we rename a text file into an image.
    It will.

    Also I wish to know if we can use exif information of an image through qt
    Probably not all info, but QImage has some method of retrieving information related to an imege. If that's not enough, you'll have to use a separate library (libexif probably).

    i tried using canRead function on a jpeg file(a true image) and it returned false when i used the error() function it showed devise error. wat might be wrong?
    You might have passed it an incorrect file name or a device it couldn't read.

  4. The following user says thank you to wysota for this useful post:


  5. #3
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    no i used the correct file name with a proper url(I used the same url to load an icon into a qlistwidget and it worked) . I used the setFileName function of qimage reader.I am pasting the code for u to look.

    Qt Code:
    1. #include <QImageReader>
    2. #include <stdio.h>
    3.  
    4. int main(int argc,char* argv[])
    5. {
    6. QImageReader *imageRead=new QImageReader();
    7. imageRead->setFileName("/home/srihari/CompaqCity.jpg");
    8. bool b;
    9. b=imageRead->canRead();
    10. if(b)
    11. {
    12. printf("true\n");
    13. }
    14. else
    15. printf("false\n");
    16.  
    17. int value=imageRead->error();
    18. printf("%d",value);
    19. }
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to sriluyarlagadda for this useful post:


  7. #4
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    guys plz help u out. I need this fixed to continue on my work......

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


  9. #5
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    sry plz help *me out

  10. The following user says thank you to sriluyarlagadda for this useful post:


  11. #6
    Join Date
    Feb 2006
    Location
    Piekary Slaskie, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    int value=imageRead->error();
    printf("%d",value);
    Which error number you have? I've got a number 3 on jpg files. It's mean that, a qt doesn't support jpg files (QImageReader::UnsupportedFormatError). I don't know why. I think packager didn't apply a properly flag to this kind of file. I have Fedora too (7).

    With bmp files, this code works.

  12. The following user says thank you to lszk for this useful post:


  13. #7
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    I got 2 and I used jpeg

  14. The following user says thank you to sriluyarlagadda for this useful post:


  15. #8
    Join Date
    May 2008
    Posts
    10
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: scanning images

    mine's device error

  16. The following user says thank you to sriluyarlagadda for this useful post:


  17. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: scanning images

    JPG files might need a plugin to work. If you installed Qt from binary packages, you probably need to install some other packages as well.

    If one image doesn't work, try another - especially PNG, support for them is embedded into Qt itself so it should always work. The device error is most likely caused by some permissions problem - check if you have read permissions for the file. You can test with a simple program:
    Qt Code:
    1. QFile file("/home/..../...jpg");
    2. if(file.isReadable()) qDebug() << "readable";
    3. qDebug() << file.open(QFile::ReadOnly);
    To copy to clipboard, switch view to plain text mode 

    You should get "readable" and "true".

  18. The following user says thank you to wysota for this useful post:


Similar Threads

  1. displayin' many images on a scence
    By peace_comp in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2008, 08:57
  2. Image Viewer for multiple images
    By sinha.ashish in forum Qt Programming
    Replies: 1
    Last Post: 25th April 2008, 16:30
  3. Release build fails to find some resource images
    By MrGarbage in forum Installation and Deployment
    Replies: 3
    Last Post: 8th December 2007, 16:04
  4. Replies: 1
    Last Post: 5th December 2006, 11:07
  5. JPEG Images not shown in QiconView using QT3??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2006, 20:34

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.