couldn't open NEF files from Nikon d5100

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
rwikee
Posts: 7
Joined: 2010-06-09T13:27:51-07:00
Authentication code: 8675308

couldn't open NEF files from Nikon d5100

Post by rwikee »

I am writing a simple image viewer using qt. I can open the NEF files using qimage , but couldn't do so using imagemagick.

here is the code i am using . It is working for many formats. But for NEF format , it throws exception and returns.

Code: Select all

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setupSignals();
    source.clear();
    ui->label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    ui->label->setScaledContents(true);
    ui->scrollArea->setAcceptDrops(false);
    setAcceptDrops(true);


}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
    if (event->mimeData()->hasFormat("text/uri-list"))
        event->acceptProposedAction();
}

void MainWindow::dropEvent(QDropEvent *event)
{
    QList<QUrl> urls = event->mimeData()->urls();
    if (urls.isEmpty())
        return;

    QString fileName = urls.first().toLocalFile();
    if (fileName.isEmpty())
        return;

    displayImage(fileName);
    // if (readFile(fileName))
    setWindowTitle(tr("%1 - %2").arg(fileName)
                   .arg(tr("Drag File")));
}

void MainWindow::displayImage(QString fileName)
{
    source = fileName;
    QImage tempImage;
    try
    {
        tempImage.load(fileName);
        //pic.read( qPrintable(fileName));
    }
    catch(Exception &error)
    {
        return;

    }


//    pic.magick("XPM");
//    pic.write(&blob);
//    imgData = ((char*)(blob.data()));
//    pixmap.loadFromData(imgData, "XPM");
    ui->label->setPixmap(QPixmap::fromImage(tempImage));

    

}

void MainWindow::adjustScrollBar(QScrollBar *scrollBar, double factor)
{
    scrollBar->setValue(int(factor * scrollBar->value()
                            + ((factor - 1) * scrollBar->pageStep()/2)));
}

void MainWindow::setupSignals()
{


    connect(ui->actionTo_jpeg_high, SIGNAL(triggered()), this, SLOT(saveHigh()));
    connect(ui->actionTo_jpeg_Mail, SIGNAL(triggered()), this, SLOT(saveLow()));


}

void MainWindow::saveHigh()
{
    if(source == NULL)
        return;
    try
    {
         pic.read( qPrintable(source));
    }
    catch(Exception &error)
    {
        return;

    }

    QString path = source.left(source.lastIndexOf("/"));
    pic.magick("JPEG");
    path += "/a.jpeg";
    pic.write(path.toStdString());


}

void MainWindow::saveLow()
{
    if(source == NULL)
        return;
    try
    {
         pic.read( qPrintable(source));
    }
    catch(Exception &error)
    {
        return;

    }

    QString path = source.left(source.lastIndexOf("/"));
    pic.magick("JPEG");
    pic.quality(40);
    path += "/a.jpeg";
    pic.write(path.toStdString());


}


snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: couldn't open NEF files from Nikon d5100

Post by snibgo »

Can you do it from the command line?

Code: Select all

convert x.NEF out.jpg
If not, then does dcraw work?

Code: Select all

dcraw x.NEF
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: couldn't open NEF files from Nikon d5100

Post by Bonzo »

If you are having a problem start with something simple first and as snibgo says try in the command line or write a bit of code that opens a NEF files and saves it without all the other code.

Just skipping through the 11 pages of search for NEF and most people open them OK but there was a post in 2008 about a new NEF format. I think you need to tell us the IM version you are using.
Post Reply