From 899c0a6543507409db192a21a9aa0e0f2e3082f1 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 11:39:37 -0400 Subject: [PATCH 01/14] Working though issue 1 --- picture.cpp | 32 +++++++------------------------- picture.h | 4 ++-- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/picture.cpp b/picture.cpp index f269c82..3dc6223 100644 --- a/picture.cpp +++ b/picture.cpp @@ -3,34 +3,10 @@ Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ ui->setupUi(this); - connect(&commandProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(log())); - connect(&commandProcess,SIGNAL(readyReadStandardError()),this,SLOT(log())); connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory())); //changeDirectory(); fillList(); } -void Picture::log(){ - QByteArray cmdoutput = commandProcess.readAllStandardOutput(); - QString txtoutput = cmdoutput; - ui->log->append(txtoutput); - cmdoutput = commandProcess.readAllStandardError(); - txtoutput = cmdoutput; - ui->log->append(txtoutput); -} - -std::string exec(char* cmd) { - FILE* pipe = popen(cmd, "r"); - if (!pipe) return "ERROR"; - char buffer[128]; - std::string result = ""; - while(!feof(pipe)) { - if(fgets(buffer, 128, pipe) != NULL){ - result += buffer; - } - } - pclose(pipe); - return result; -} Picture::~Picture(){ delete ui; } @@ -72,7 +48,13 @@ void Picture::on_erase_clicked(){ a[tmp2.size()]=0; memcpy(a,tmp2.c_str(),tmp2.size()); //exec(a); - commandProcess.start(a); + ui->log->append(str); + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(str.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + Exiv2::ExifData &exifData = image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; + image->writeMetadata(); }else{ if(!ignored){ ignored=true; diff --git a/picture.h b/picture.h index ed733cf..807861f 100644 --- a/picture.h +++ b/picture.h @@ -14,6 +14,8 @@ #include #include #include +#include +#include namespace Ui { class Picture; @@ -35,10 +37,8 @@ private slots: void on_refresh_clicked(); void on_clearLog_clicked(); void on_erase_pressed(); - void log(); private: Ui::Picture *ui; QDir directory; - QProcess commandProcess; }; #endif // PICTURE_H From e8448b97bddd6bba0815fe2958f80ce2d449fd99 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 11:48:16 -0400 Subject: [PATCH 02/14] Fixes #1 --- picture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/picture.cpp b/picture.cpp index 3dc6223..d527653 100644 --- a/picture.cpp +++ b/picture.cpp @@ -48,8 +48,9 @@ void Picture::on_erase_clicked(){ a[tmp2.size()]=0; memcpy(a,tmp2.c_str(),tmp2.size()); //exec(a); - ui->log->append(str); - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(str.toStdString()); + //ui->log->append(str); + QString fullPath=directory.absolutePath()+"/"+str; + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); assert (image.get() != 0); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); From c912db7324651e4ba05fc784004309ecb1be6335 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 12:25:07 -0400 Subject: [PATCH 03/14] Added Images tab to add or remove images --- picture.ui | 107 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 94 insertions(+), 13 deletions(-) diff --git a/picture.ui b/picture.ui index 2d8eb55..fb0cfc1 100644 --- a/picture.ui +++ b/picture.ui @@ -6,8 +6,8 @@ 0 0 - 656 - 350 + 658 + 434 @@ -19,12 +19,12 @@ 0 0 - 471 - 301 + 411 + 341 - 0 + 1 @@ -36,7 +36,7 @@ 20 20 258 - 229 + 281 @@ -63,7 +63,7 @@ - + 300 @@ -83,17 +83,98 @@ - Label + Caption - fileList - fileList layoutWidget - erase - pushButton + layoutWidget + + + + Images + + + + + 0 + 0 + 401 + 311 + + + + + + + + + + + + + + Previous (k) + + + + + + + Remove (Space) + + + + + + + Next (j) + + + + + + + + + + + Image + + + + + + + + + -1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + + + + -1 + + + + + + + @@ -133,7 +214,7 @@ 0 0 - 656 + 658 21 From bc51ea6a3cbbf5f3e736d3020a4063e4a2cfc785 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 14:13:48 -0400 Subject: [PATCH 04/14] Now succesfully adds files from drag and drop --- picture.cpp | 38 +++++++++++-- picture.h | 3 + picture.ui | 161 ++++++++++++++++++++++------------------------------ 3 files changed, 106 insertions(+), 96 deletions(-) diff --git a/picture.cpp b/picture.cpp index d527653..0f3d712 100644 --- a/picture.cpp +++ b/picture.cpp @@ -1,15 +1,39 @@ #include "picture.h" +#include +#include +#include +#include Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ ui->setupUi(this); connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory())); + setAcceptDrops(true); //changeDirectory(); fillList(); } Picture::~Picture(){ delete ui; } +void Picture::dragEnterEvent(QDragEnterEvent *event){ + if(event->mimeData()->hasUrls()){ + event->acceptProposedAction(); + + } +} +void Picture::dropEvent(QDropEvent *event){ + foreach (const QUrl &url, event->mimeData()->urls()) { + const QString &fileName = url.toLocalFile(); + + //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ + ui->fileList->addItem(fileName); + //}else{ + // qDebug()<fileList->count()==0){ - ui->fileList->addItem(""); + //ui->fileList->addItem(""); } } void Picture::on_cd_clicked(){ @@ -38,7 +62,12 @@ void Picture::on_cd_clicked(){ } void Picture::on_erase_clicked(){ bool ignored=false; - foreach(const QString &str,directory.entryList()){ + QStringList myStringList; + for (int i = 0; i < ui->fileList->count(); ++i) + myStringList.append(ui->fileList->item(i)->text()); + qDebug() << myStringList; + //foreach(const QString &str,directory.entryList()){ + foreach(const QString &str,myStringList){ QString tmp=QString("exiv2 rm "); QImageReader reader(directory.absolutePath()+"/"+str); if(!reader.format().isEmpty()){ @@ -67,8 +96,9 @@ void Picture::on_erase_clicked(){ ui->log->append("Done erasing metadata"); } void Picture::on_refresh_clicked(){ - fillList(); - ui->log->append("Refreshed directory"); + //fillList(); + ui->fileList->clear(); + ui->log->append("Cleared File List"); } void Picture::on_clearLog_clicked(){ ui->log->setText(""); diff --git a/picture.h b/picture.h index 807861f..fb9b6ad 100644 --- a/picture.h +++ b/picture.h @@ -40,5 +40,8 @@ private slots: private: Ui::Picture *ui; QDir directory; +protected: + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); }; #endif // PICTURE_H diff --git a/picture.ui b/picture.ui index 2d8eb55..a118bd9 100644 --- a/picture.ui +++ b/picture.ui @@ -7,7 +7,7 @@ 0 0 656 - 350 + 463 @@ -19,8 +19,8 @@ 0 0 - 471 - 301 + 393 + 279 @@ -30,101 +30,78 @@ Commands - - - - 20 - 20 - 258 - 229 - - - - - - - - - - - - Change Directory - - - - - - - Refresh Directory - - - - - - - - - - - 300 - 60 - 107 - 62 - - - - - - - Erase Metadata - - - - - - - Label - - - - - - fileList - fileList + + + + + + + + + + + + Change Directory + + + + + + + Clear File List + + + + + + + + + + + + + Erase Metadata + + + + + + + Label + + + + + + + layoutWidget layoutWidget - erase - pushButton Log - - - - 10 - 10 - 381 - 192 - - - - true - - - - - - 270 - 220 - 51 - 30 - - - - Clear - - + + + + + + + true + + + + + + + Clear + + + + + + From dd1400e35d474ec4c55f7b1c192b1dedcde35388 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 14:17:12 -0400 Subject: [PATCH 05/14] Now succesfully adds files from drag and drop --- picture.ui | 162 +---------------------------------------------------- 1 file changed, 2 insertions(+), 160 deletions(-) diff --git a/picture.ui b/picture.ui index f2a5912..a118bd9 100644 --- a/picture.ui +++ b/picture.ui @@ -6,13 +6,8 @@ 0 0 -<<<<<<< HEAD - 658 - 434 -======= 656 463 ->>>>>>> tmp @@ -24,169 +19,17 @@ 0 0 -<<<<<<< HEAD - 411 - 341 -======= 393 279 ->>>>>>> tmp - 1 + 0 Commands -<<<<<<< HEAD - - - - 20 - 20 - 258 - 281 - - - - - - - - - - - - Change Directory - - - - - - - Refresh Directory - - - - - - - - - - - 300 - 60 - 107 - 62 - - - - - - - Erase Metadata - - - - - - - Caption - - - - - - layoutWidget - layoutWidget - - - - Images - - - - - 0 - 0 - 401 - 311 - - - - - - - - - - - - - - Previous (k) - - - - - - - Remove (Space) - - - - - - - Next (j) - - - - - - - - - - - Image - - - - - - - - - -1 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - - - - - -1 - - - - - - - -======= @@ -234,7 +77,6 @@ layoutWidget layoutWidget ->>>>>>> tmp @@ -268,7 +110,7 @@ 0 0 - 658 + 656 21 From 5e400c5d51d97f9da7446c09606274eed0b495ed Mon Sep 17 00:00:00 2001 From: Austen Date: Fri, 20 Jun 2014 13:39:10 -0400 Subject: [PATCH 06/14] Fixes directory problem with drag and rop --- Picture.pro | 3 +-- Picture.pro.user | 2 +- picture.cpp | 46 +++++++++++++-------------------- picture.ui | 6 ++--- preview.ui | 66 ------------------------------------------------ 5 files changed, 22 insertions(+), 101 deletions(-) delete mode 100644 preview.ui diff --git a/Picture.pro b/Picture.pro index 9e8b806..8de8f4f 100644 --- a/Picture.pro +++ b/Picture.pro @@ -17,8 +17,7 @@ SOURCES += main.cpp\ HEADERS += picture.h -FORMS += picture.ui \ - preview.ui +FORMS += picture.ui unix: CONFIG += link_pkgconfig unix: PKGCONFIG += exiv2 diff --git a/Picture.pro.user b/Picture.pro.user index 259c700..6bb30be 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index 0f3d712..2bf85b6 100644 --- a/picture.cpp +++ b/picture.cpp @@ -16,22 +16,20 @@ Picture::~Picture(){ delete ui; } void Picture::dragEnterEvent(QDragEnterEvent *event){ - if(event->mimeData()->hasUrls()){ - event->acceptProposedAction(); - - } + if(event->mimeData()->hasUrls()){ + event->acceptProposedAction(); + } } void Picture::dropEvent(QDropEvent *event){ - foreach (const QUrl &url, event->mimeData()->urls()) { - const QString &fileName = url.toLocalFile(); - - //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ - ui->fileList->addItem(fileName); - //}else{ - // qDebug()<mimeData()->urls()) { + const QString &fileName = url.toLocalFile(); + //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ + ui->fileList->addItem(fileName); + //}else{ + // qDebug()<fileList->count(); ++i) - myStringList.append(ui->fileList->item(i)->text()); - qDebug() << myStringList; + QStringList myStringList; + for (int i = 0; i < ui->fileList->count(); ++i) + myStringList.append(ui->fileList->item(i)->text()); + qDebug() << myStringList; //foreach(const QString &str,directory.entryList()){ foreach(const QString &str,myStringList){ - QString tmp=QString("exiv2 rm "); - QImageReader reader(directory.absolutePath()+"/"+str); + QImageReader reader(str); if(!reader.format().isEmpty()){ - tmp+=directory.absolutePath()+"/"+str+">>/tmp/log"; - std::string tmp2=tmp.toStdString(); - char* a=new char[tmp2.size()+1]; - a[tmp2.size()]=0; - memcpy(a,tmp2.c_str(),tmp2.size()); - //exec(a); - //ui->log->append(str); - QString fullPath=directory.absolutePath()+"/"+str; + QString fullPath=str; Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); assert (image.get() != 0); image->readMetadata(); diff --git a/picture.ui b/picture.ui index a118bd9..25dae5b 100644 --- a/picture.ui +++ b/picture.ui @@ -19,8 +19,8 @@ 0 0 - 393 - 279 + 521 + 411 @@ -75,8 +75,6 @@ - layoutWidget - layoutWidget diff --git a/preview.ui b/preview.ui deleted file mode 100644 index 92cccb3..0000000 --- a/preview.ui +++ /dev/null @@ -1,66 +0,0 @@ - - - Dialog - - - - 0 - 0 - 432 - 334 - - - - Dialog - - - - - 1 - 1 - 120 - 16 - - - - Process this picture? - - - - - - 1 - 22 - 431 - 311 - - - - - - - - - - No (n) - - - - - - - Yes (y) - - - - - - buttonBox - image - buttonBox - noButton - yesButton - - - - From fdfdffc9b0469f674c2a152308f30c203eb55cc3 Mon Sep 17 00:00:00 2001 From: Austen Date: Fri, 20 Jun 2014 14:35:39 -0400 Subject: [PATCH 07/14] Exiv2 error handling implemented. Now it doesn't crash when there's a gif --- picture.cpp | 22 +++++++++++++++------- picture.ui | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/picture.cpp b/picture.cpp index 2bf85b6..e32f443 100644 --- a/picture.cpp +++ b/picture.cpp @@ -3,6 +3,7 @@ #include #include #include +#include Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ @@ -31,7 +32,6 @@ void Picture::dropEvent(QDropEvent *event){ //qDebug() << "Dropped file:" << fileName; } } - void Picture::changeDirectory(){ QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); if(path.isNull()==false){ @@ -69,12 +69,20 @@ void Picture::on_erase_clicked(){ QImageReader reader(str); if(!reader.format().isEmpty()){ QString fullPath=str; - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); - image->readMetadata(); - Exiv2::ExifData &exifData = image->exifData(); - exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; - image->writeMetadata(); + try{ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + Exiv2::ExifData &exifData = image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; + image->writeMetadata(); + }catch(Exiv2::AnyError& e){ + QMessageBox msgBox; + msgBox.setInformativeText("The program could not process the file: "+fullPath); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret=msgBox.exec(); + } }else{ if(!ignored){ ignored=true; diff --git a/picture.ui b/picture.ui index 25dae5b..5ad7038 100644 --- a/picture.ui +++ b/picture.ui @@ -41,7 +41,7 @@ - Change Directory + Open Directory From 8d5e2e4e81b1e966bccbf2d727381961c2297617 Mon Sep 17 00:00:00 2001 From: Austen Date: Sat, 21 Jun 2014 17:17:00 -0400 Subject: [PATCH 08/14] Added label functionality. Erase and label functionality now works 100picture.cpp. Starting to work on "Erase GPS data" checkbox now... --- picture.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- picture.h | 4 ++++ picture.ui | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/picture.cpp b/picture.cpp index e32f443..c26cb08 100644 --- a/picture.cpp +++ b/picture.cpp @@ -18,6 +18,7 @@ Picture::~Picture(){ } void Picture::dragEnterEvent(QDragEnterEvent *event){ if(event->mimeData()->hasUrls()){ + ui->tabField->setCurrentIndex(0); event->acceptProposedAction(); } } @@ -73,8 +74,7 @@ void Picture::on_erase_clicked(){ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); assert (image.get() != 0); image->readMetadata(); - Exiv2::ExifData &exifData = image->exifData(); - exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; + image->clearMetadata(); image->writeMetadata(); }catch(Exiv2::AnyError& e){ QMessageBox msgBox; @@ -107,3 +107,44 @@ void Picture::on_erase_pressed(){ ui->tabField->setCurrentIndex(1); on_erase_clicked(); } +void Picture::on_processButton_pressed(){ + ui->log->append("Processing images..."); + ui->tabField->setCurrentIndex(1); + on_processButton_clicked(); +} +void Picture::on_processButton_clicked(){ + bool ignored=false; + QStringList myStringList; + for (int i = 0; i < ui->fileList->count(); ++i) + myStringList.append(ui->fileList->item(i)->text()); + qDebug() << myStringList; + //foreach(const QString &str,directory.entryList()){ + foreach(const QString &str,myStringList){ + QImageReader reader(str); + if(!reader.format().isEmpty()){ + QString fullPath=str; + try{ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + Exiv2::ExifData &exifData = image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); + image->writeMetadata(); + }catch(Exiv2::AnyError& e){ + QMessageBox msgBox; + msgBox.setInformativeText("The program could not process the file: "+fullPath); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret=msgBox.exec(); + } + }else{ + if(!ignored){ + ignored=true; + ui->log->append("Ignored Files:"); + } + ui->log->append(str); + } + } + ui->log->append("Done erasing metadata"); +} + diff --git a/picture.h b/picture.h index fb9b6ad..509deb8 100644 --- a/picture.h +++ b/picture.h @@ -37,6 +37,10 @@ private slots: void on_refresh_clicked(); void on_clearLog_clicked(); void on_erase_pressed(); + void on_processButton_clicked(); + + void on_processButton_pressed(); + private: Ui::Picture *ui; QDir directory; diff --git a/picture.ui b/picture.ui index 5ad7038..a9b7df2 100644 --- a/picture.ui +++ b/picture.ui @@ -19,7 +19,7 @@ 0 0 - 521 + 651 411 @@ -66,12 +66,42 @@ - + + + Qt::Vertical + + + + 20 + 40 + + + + + + Label + + + + + + + Erase GPS Data + + + + + + + Process + + + From e722dea0dce045513b18de5fa4c7a5896dc5121c Mon Sep 17 00:00:00 2001 From: Austen Date: Sun, 22 Jun 2014 19:51:33 -0400 Subject: [PATCH 09/14] "Erase Other Metadata" checkbox added and works correctly --- Picture.pro.user | 2 +- picture.cpp | 64 +++++++++++++++++++++++++----------------------- picture.ui | 28 +++++++++++++++++++-- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/Picture.pro.user b/Picture.pro.user index 6bb30be..4b7332a 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index c26cb08..0e6caef 100644 --- a/picture.cpp +++ b/picture.cpp @@ -113,38 +113,40 @@ void Picture::on_processButton_pressed(){ on_processButton_clicked(); } void Picture::on_processButton_clicked(){ - bool ignored=false; - QStringList myStringList; - for (int i = 0; i < ui->fileList->count(); ++i) - myStringList.append(ui->fileList->item(i)->text()); - qDebug() << myStringList; - //foreach(const QString &str,directory.entryList()){ - foreach(const QString &str,myStringList){ - QImageReader reader(str); - if(!reader.format().isEmpty()){ - QString fullPath=str; - try{ - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); - image->readMetadata(); - Exiv2::ExifData &exifData = image->exifData(); - exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); - image->writeMetadata(); - }catch(Exiv2::AnyError& e){ - QMessageBox msgBox; - msgBox.setInformativeText("The program could not process the file: "+fullPath); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret=msgBox.exec(); + bool ignored=false; + QStringList myStringList; + for (int i=0;ifileList->count();++i){ + myStringList.append(ui->fileList->item(i)->text()); + } + qDebug()<readMetadata(); + if(ui->eraseOtherMetadata->isChecked()){ + image->clearMetadata(); } - }else{ - if(!ignored){ - ignored=true; - ui->log->append("Ignored Files:"); - } - ui->log->append(str); + Exiv2::ExifData &exifData=image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); + image->writeMetadata(); + }catch(Exiv2::AnyError& e){ + QMessageBox msgBox; + msgBox.setInformativeText("The program could not process the file: "+fullPath); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); } + }else{ + if(!ignored){ + ignored=true; + ui->log->append("Ignored Files:"); + } + ui->log->append(str); } - ui->log->append("Done erasing metadata"); + } + ui->log->append("Done erasing metadata"); } - diff --git a/picture.ui b/picture.ui index a9b7df2..ea002ac 100644 --- a/picture.ui +++ b/picture.ui @@ -61,7 +61,7 @@ - Erase Metadata + Erase All Metadata @@ -88,6 +88,13 @@ + + + + Erase Other Metadata + + + @@ -167,5 +174,22 @@ - + + + eraseOtherMetadata + toggled(bool) + eraseGpsData + setDisabled(bool) + + + 428 + 367 + + + 432 + 387 + + + + From a31d57a339c99dca29f71fd62f86f44b8b2356fc Mon Sep 17 00:00:00 2001 From: Austen Date: Sun, 22 Jun 2014 20:14:42 -0400 Subject: [PATCH 10/14] Formatted and fixed compile bug in picture.h --- Picture.pro.user | 4 ++-- main.cpp | 13 +++++-------- picture.cpp | 7 +------ picture.h | 30 ++++++++++++++---------------- 4 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Picture.pro.user b/Picture.pro.user index 4b7332a..b8873f4 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -54,7 +54,7 @@ Desktop Desktop {78915aca-1f52-4c43-bbd6-02dcf5b6f6cf} - 0 + 1 0 0 diff --git a/main.cpp b/main.cpp index 7aa843b..3947d14 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,8 @@ #include "picture.h" #include - - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Picture w; - w.show(); - return a.exec(); +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + Picture w; + w.show(); + return a.exec(); } diff --git a/picture.cpp b/picture.cpp index 0e6caef..2816bef 100644 --- a/picture.cpp +++ b/picture.cpp @@ -1,9 +1,4 @@ #include "picture.h" -#include -#include -#include -#include -#include Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ @@ -128,7 +123,7 @@ void Picture::on_processButton_clicked(){ assert (image.get() != 0); image->readMetadata(); if(ui->eraseOtherMetadata->isChecked()){ - image->clearMetadata(); + image->clearMetadata(); } Exiv2::ExifData &exifData=image->exifData(); exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); diff --git a/picture.h b/picture.h index 509deb8..0f7f402 100644 --- a/picture.h +++ b/picture.h @@ -1,11 +1,9 @@ #ifndef PICTURE_H #define PICTURE_H - #include #include #include #include "ui_picture.h" -#include "ui_preview.h" #include #include #include @@ -16,21 +14,23 @@ #include #include #include - +#include +#include +#include +#include +#include namespace Ui { - class Picture; - class Preview; + class Picture; + class Preview; } +class Picture : public QMainWindow { + Q_OBJECT -class Picture : public QMainWindow -{ - Q_OBJECT - -public: + public: explicit Picture(QWidget *parent = 0); ~Picture(); -private slots: - void changeDirectory(); + private slots: + void changeDirectory(); void fillList(); void on_cd_clicked(); void on_erase_clicked(); @@ -38,13 +38,11 @@ private slots: void on_clearLog_clicked(); void on_erase_pressed(); void on_processButton_clicked(); - void on_processButton_pressed(); - -private: + private: Ui::Picture *ui; QDir directory; -protected: + protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); }; From 88ab8a2500258bb65bf6c260097174e6004f2fc2 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Mon, 23 Jun 2014 02:58:27 -0400 Subject: [PATCH 11/14] Added gitignore file to ignore Picture.pro.user --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6342be1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Picture.pro.user \ No newline at end of file From b346ed838bedf1709e8c8819c2505ecc6809fc90 Mon Sep 17 00:00:00 2001 From: Austen Date: Mon, 23 Jun 2014 23:51:36 -0400 Subject: [PATCH 12/14] Changed two buttons to two radiobuttons of "Label Images" and "Erase All Metadata" --- .gitignore | 2 +- Picture.pro.user | 2 +- picture.cpp | 70 ++++++++++------------------------------- picture.h | 2 -- picture.ui | 82 ++++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 91 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index 6342be1..cc40fd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -Picture.pro.user \ No newline at end of file +./Picture.pro.user diff --git a/Picture.pro.user b/Picture.pro.user index b8873f4..0dd141d 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index 2816bef..2aeeef3 100644 --- a/picture.cpp +++ b/picture.cpp @@ -20,12 +20,7 @@ void Picture::dragEnterEvent(QDragEnterEvent *event){ void Picture::dropEvent(QDropEvent *event){ foreach (const QUrl &url, event->mimeData()->urls()) { const QString &fileName = url.toLocalFile(); - //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ ui->fileList->addItem(fileName); - //}else{ - // qDebug()<fileList->addItem(str); + QString itemString=directory.path()+"/"+str; + ui->fileList->addItem(itemString); } } if(ui->fileList->count()==0){ @@ -54,40 +50,6 @@ void Picture::fillList() { void Picture::on_cd_clicked(){ changeDirectory(); } -void Picture::on_erase_clicked(){ - bool ignored=false; - QStringList myStringList; - for (int i = 0; i < ui->fileList->count(); ++i) - myStringList.append(ui->fileList->item(i)->text()); - qDebug() << myStringList; - //foreach(const QString &str,directory.entryList()){ - foreach(const QString &str,myStringList){ - QImageReader reader(str); - if(!reader.format().isEmpty()){ - QString fullPath=str; - try{ - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); - image->readMetadata(); - image->clearMetadata(); - image->writeMetadata(); - }catch(Exiv2::AnyError& e){ - QMessageBox msgBox; - msgBox.setInformativeText("The program could not process the file: "+fullPath); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret=msgBox.exec(); - } - }else{ - if(!ignored){ - ignored=true; - ui->log->append("Ignored Files:"); - } - ui->log->append(str); - } - } - ui->log->append("Done erasing metadata"); -} void Picture::on_refresh_clicked(){ //fillList(); ui->fileList->clear(); @@ -97,11 +59,6 @@ void Picture::on_clearLog_clicked(){ ui->log->setText(""); ui->tabField->setCurrentIndex(0); } -void Picture::on_erase_pressed(){ - ui->log->append("Erasing metadata from images..."); - ui->tabField->setCurrentIndex(1); - on_erase_clicked(); -} void Picture::on_processButton_pressed(){ ui->log->append("Processing images..."); ui->tabField->setCurrentIndex(1); @@ -113,21 +70,28 @@ void Picture::on_processButton_clicked(){ for (int i=0;ifileList->count();++i){ myStringList.append(ui->fileList->item(i)->text()); } - qDebug()<readMetadata(); - if(ui->eraseOtherMetadata->isChecked()){ + if(ui->labelImagesRadio->isChecked()){ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + if(ui->eraseOtherMetadata->isChecked()){ + image->clearMetadata(); + } + Exiv2::ExifData &exifData=image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); + image->writeMetadata(); + }else{ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); + assert (image.get() != 0); + image->readMetadata(); image->clearMetadata(); + image->writeMetadata(); } - Exiv2::ExifData &exifData=image->exifData(); - exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); - image->writeMetadata(); }catch(Exiv2::AnyError& e){ QMessageBox msgBox; msgBox.setInformativeText("The program could not process the file: "+fullPath); diff --git a/picture.h b/picture.h index 0f7f402..d5ba9b4 100644 --- a/picture.h +++ b/picture.h @@ -33,10 +33,8 @@ class Picture : public QMainWindow { void changeDirectory(); void fillList(); void on_cd_clicked(); - void on_erase_clicked(); void on_refresh_clicked(); void on_clearLog_clicked(); - void on_erase_pressed(); void on_processButton_clicked(); void on_processButton_pressed(); private: diff --git a/picture.ui b/picture.ui index ea002ac..a319615 100644 --- a/picture.ui +++ b/picture.ui @@ -6,8 +6,8 @@ 0 0 - 656 - 463 + 783 + 607 @@ -58,13 +58,6 @@ - - - - Erase All Metadata - - - @@ -78,6 +71,27 @@ + + + + + + Label Images + + + true + + + + + + + Erase All Metadata + + + + + @@ -145,7 +159,7 @@ 0 0 - 656 + 783 21 @@ -191,5 +205,53 @@ + + eraseAllRadio + toggled(bool) + labelText + setDisabled(bool) + + + 527 + 120 + + + 457 + 332 + + + + + eraseAllRadio + toggled(bool) + eraseOtherMetadata + setDisabled(bool) + + + 583 + 120 + + + 381 + 369 + + + + + eraseAllRadio + toggled(bool) + eraseGpsData + setDisabled(bool) + + + 601 + 118 + + + 539 + 386 + + + From ab3fe277b52813490709440af65938056b3498a5 Mon Sep 17 00:00:00 2001 From: Austen Date: Tue, 24 Jun 2014 00:07:14 -0400 Subject: [PATCH 13/14] Fixed small issues and added markers --- picture.cpp | 65 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/picture.cpp b/picture.cpp index 2aeeef3..3c5b144 100644 --- a/picture.cpp +++ b/picture.cpp @@ -1,4 +1,7 @@ +//Includes{{{ #include "picture.h" +//}}} +//Decleration{{{ Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ @@ -11,6 +14,8 @@ Picture::Picture(QWidget *parent) : Picture::~Picture(){ delete ui; } +//}}} +//Drag and Drop{{{ void Picture::dragEnterEvent(QDragEnterEvent *event){ if(event->mimeData()->hasUrls()){ ui->tabField->setCurrentIndex(0); @@ -23,6 +28,23 @@ void Picture::dropEvent(QDropEvent *event){ ui->fileList->addItem(fileName); } } +//}}} +//Fill List{{{ +void Picture::fillList() { + ui->fileList->clear(); + foreach(const QString &str,directory.entryList()){ + QImageReader reader(directory.absolutePath()+"/"+str); + if(!reader.format().isEmpty()){ + QString itemString=directory.path()+"/"+str; + ui->fileList->addItem(itemString); + } + } +} +//}}} +//Change Directory{{{ +void Picture::on_cd_clicked(){ + changeDirectory(); +} void Picture::changeDirectory(){ QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); if(path.isNull()==false){ @@ -33,48 +55,41 @@ void Picture::changeDirectory(){ ui->log->append("Could not change directory"); } } -void Picture::fillList() { - ui->fileList->clear(); - //ui->fileList->addItems(directory.entryList()); - foreach(const QString &str,directory.entryList()){ - QImageReader reader(directory.absolutePath()+"/"+str); - if(!reader.format().isEmpty()){ - QString itemString=directory.path()+"/"+str; - ui->fileList->addItem(itemString); - } - } - if(ui->fileList->count()==0){ - //ui->fileList->addItem(""); - } -} -void Picture::on_cd_clicked(){ - changeDirectory(); -} +//}}} +//Clear File List{{{ void Picture::on_refresh_clicked(){ - //fillList(); ui->fileList->clear(); ui->log->append("Cleared File List"); } +//}}} +//Clear Log{{{ void Picture::on_clearLog_clicked(){ ui->log->setText(""); ui->tabField->setCurrentIndex(0); } +//}}} +//Process Images{{{ +//Switch Tab{{{ void Picture::on_processButton_pressed(){ ui->log->append("Processing images..."); ui->tabField->setCurrentIndex(1); on_processButton_clicked(); } +//}}} void Picture::on_processButton_clicked(){ bool ignored=false; + //Populate File List{{{ QStringList myStringList; - for (int i=0;ifileList->count();++i){ + for(int i=0;ifileList->count();++i){ myStringList.append(ui->fileList->item(i)->text()); } + //}}} foreach(const QString &str,myStringList){ QImageReader reader(str); if(!reader.format().isEmpty()){ QString fullPath=str; try{ + //Label Images{{{ if(ui->labelImagesRadio->isChecked()){ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); assert (image.get() != 0); @@ -85,13 +100,17 @@ void Picture::on_processButton_clicked(){ Exiv2::ExifData &exifData=image->exifData(); exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); image->writeMetadata(); + //}}} + //Erase Metadata{{{ }else{ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); + assert(image.get()!=0); image->readMetadata(); image->clearMetadata(); image->writeMetadata(); } + //}}} + //Catch{{{ }catch(Exiv2::AnyError& e){ QMessageBox msgBox; msgBox.setInformativeText("The program could not process the file: "+fullPath); @@ -99,6 +118,8 @@ void Picture::on_processButton_clicked(){ msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); } + //}}} + //List Ignored Files{{{ }else{ if(!ignored){ ignored=true; @@ -106,6 +127,8 @@ void Picture::on_processButton_clicked(){ } ui->log->append(str); } + //}}} } - ui->log->append("Done erasing metadata"); + ui->log->append("Done processing metadata"); } +//}}} From ad161bdb706d66e3a8fc8c18268799fe8f7df7b3 Mon Sep 17 00:00:00 2001 From: Austen Date: Wed, 25 Jun 2014 19:58:22 -0400 Subject: [PATCH 14/14] Added text edit field to edit gps data. Works. --- Picture.pro.user | 2 +- picture.cpp | 21 ++++++++++++++++++++- picture.h | 4 +++- picture.ui | 14 ++------------ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Picture.pro.user b/Picture.pro.user index 0dd141d..f394213 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index 3c5b144..9195f63 100644 --- a/picture.cpp +++ b/picture.cpp @@ -92,7 +92,7 @@ void Picture::on_processButton_clicked(){ //Label Images{{{ if(ui->labelImagesRadio->isChecked()){ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); - assert (image.get() != 0); + assert (image.get()!=0); image->readMetadata(); if(ui->eraseOtherMetadata->isChecked()){ image->clearMetadata(); @@ -132,3 +132,22 @@ void Picture::on_processButton_clicked(){ ui->log->append("Done processing metadata"); } //}}} +void Picture::on_fileList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) { + ui->gpsData->clear(); + QString tmp=current->text(); + std::string tmp2=tmp.toStdString(); + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(tmp2); + assert(image.get()!=0); + image->readMetadata(); + Exiv2::ExifData &exifData=image->exifData(); + std::string arrStr[7]={"GPSLatitudeRef","GPSLatitude","GPSLongitudeRef","GPSLongitude","GPSAltitudeRef","GPSAltitude","GPSTimeStamp"}; + for(int i=0;i<7;i++){ + Exiv2::Exifdatum gps=exifData["Exif.GPSInfo."+arrStr[i]]; + std::string a; + a=gps.toString(); + ui->gpsData->append(QString::fromStdString(a)); + //qDebug()<gpsData->append(GPSLatitudeRef.toString()); */ + +} diff --git a/picture.h b/picture.h index d5ba9b4..ed14778 100644 --- a/picture.h +++ b/picture.h @@ -37,7 +37,9 @@ class Picture : public QMainWindow { void on_clearLog_clicked(); void on_processButton_clicked(); void on_processButton_pressed(); - private: + void on_fileList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); + +private: Ui::Picture *ui; QDir directory; protected: diff --git a/picture.ui b/picture.ui index a319615..8792506 100644 --- a/picture.ui +++ b/picture.ui @@ -59,17 +59,7 @@ - - - Qt::Vertical - - - - 20 - 40 - - - + @@ -112,7 +102,7 @@ - Erase GPS Data + Set GPS Data From Above