summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2015-10-11 08:16:28 +0200
committerArno <arno@disconnect.de>2015-10-11 08:16:28 +0200
commit55d48519c9132c6d213f2e733bcd806e3b1f05fb (patch)
treeccaec3219ebfb05ea9a742398ee5e4c47713eae5
parentb8c44e336b596aa45f4fd4054353912b73b71e66 (diff)
downloadSheMov-55d48519c9132c6d213f2e733bcd806e3b1f05fb.tar.gz
SheMov-55d48519c9132c6d213f2e733bcd806e3b1f05fb.tar.bz2
SheMov-55d48519c9132c6d213f2e733bcd806e3b1f05fb.zip
Change image size calculation
Use ImageMagick::Image::ping to determine the size of an image, but only if the file size is < 400kb to prevent the impression of a deadlock.
-rw-r--r--delegates.cpp2
-rw-r--r--helper.cpp10
-rw-r--r--smdirwatcher.cpp8
3 files changed, 11 insertions, 9 deletions
diff --git a/delegates.cpp b/delegates.cpp
index 927726c..db4b6b1 100644
--- a/delegates.cpp
+++ b/delegates.cpp
@@ -81,7 +81,7 @@ QString SizeDelegate::displayText(const QVariant &value, const QLocale &locale)
QString DurationDelegate::displayText(const QVariant &value, const QLocale &locale) const{
Q_UNUSED(locale);
- if(value.toString().contains("x")){
+ if(value.toString().contains("x") || value.toString() == "skipped"){
return value.toString();
}
int secs = value.toFloat();
diff --git a/helper.cpp b/helper.cpp
index ed1d31a..dd6bedf 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -308,12 +308,10 @@ namespace Helper {
}
QVariant picSize(const QString &path){
- QImage img(path);
- if(!img.isNull()){
- QString retval = QString("%1x%2").arg(QString::number(img.width())).arg(QString::number(img.height()));
- return retval;
- }
- return QVariant();
+ Magick::Image img;
+ img.ping(qPrintable(path));
+ QString retval = QString("%1x%2").arg(QString::number(img.columns())).arg(QString::number(img.rows()));
+ return retval;
}
PicData convertToPng(PicData data){
diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp
index 79bce7c..2bcaff3 100644
--- a/smdirwatcher.cpp
+++ b/smdirwatcher.cpp
@@ -75,8 +75,12 @@ QList<QVariant> SmDirWatcher::generalData(const QString &path){
QVariantMap m = Helper::ffmpegData(fi.absoluteFilePath());
data << m.value("duration") << m.value("bit_rate");
}else if(mime.startsWith("image")){
- QVariant picSize = Helper::picSize(fi.absoluteFilePath());
- data << picSize << QVariant();
+ if(fi.size() > 1024*400){ //skip images bigger than 300 kb
+ data << "skipped" << QVariant();
+ }else{
+ QVariant picSize = Helper::picSize(fi.absoluteFilePath());
+ data << picSize << QVariant();
+ }
}else{
data << QVariant() << QVariant();
}