Results 1 to 2 of 2

Thread: Use QImageReader to test image files

  1. #1

    Default Use QImageReader to test image files

    I had a hard drive loaded with images go south on me leaving about 20% of them corrupted. I was looking for a way to check for the ones that are corrupted using QImage or QImage Reader. If I do some thing like

    Qt Code:
    1. #include <QImageReader>
    2.  
    3. QString test;
    4. QIODevice *device;
    5.  
    6. //Some function to get a bunch of file names here, loop through them and place them one at a time into test.
    7.  
    8.  
    9. image.setDevice(device);
    10. image.setFileName(test);
    11. image.read();
    12.  
    13. qDebug()<<image.error()<<image.errorString()<<test;
    To copy to clipboard, switch view to plain text mode 

    I get output like the following in the application output.

    0 "Unknown error" "/mnt/media/pics/image1.jpg"
    0 "Unknown error" "/mnt/media/pics/image2.jpg"
    0 "Unknown error" "/mnt/media/pics/image3.jpg"
    0 "Unknown error" "/mnt/media/pics/image4.jpg"
    Corrupt JPEG data: bad Huffman code
    0 "Unknown error" "/mnt/media/pics/image5.jpg"
    Corrupt JPEG data: premature end of data segment
    0 "Unknown error" "/mnt/media/pics/image6.jpg"
    0 "Unknown error" "/mnt/media/pics/image7.jpg"
    0 "Unknown error" "/mnt/media/pics/image8.jpg"

    So reading the the error code and error string are not telling me when the images are corrupted but some thing, some where, is detecting the corrupt images and dumping it to the out put but I have no idea what. Can any one tell me how to gain access those Corrupt JPEG messages, Tell me what is putting it into the output or suggest how I could read the output from my application from within the application so I could catch when these messages are being written to the output.

    In case it helps the files after the Corrupt JPEG messages are the ones that are hosed.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Posts
    25
    Thanked 2 Times in 2 Posts

    Default Re: Use QImageReader to test image files

    I can't answer your question but I have a solution.

    Those messages might not even be output by the Qt library but the low level library it uses.

    Why not redirect the output of your program to a log file then analyze the log later with another program.

    your_image_tester > log.txt

    log_analyzer log.txt

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  3. Explanation to Image Formats
    By sincnarf in forum Qt Programming
    Replies: 13
    Last Post: 6th July 2007, 17:02
  4. qmake doesn't like image files starting with "r"
    By Pepe in forum Qt Programming
    Replies: 8
    Last Post: 5th April 2007, 00:03
  5. Replies: 2
    Last Post: 7th November 2006, 12:49

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.