Skip to content

Commit

Permalink
More efficient image size calculation for base64 encoded images
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2018
1 parent 9d28a96 commit 7a5f553
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/qgsimagecache.cpp
Expand Up @@ -160,6 +160,11 @@ QSize QgsImageCache::originalSize( const QString &path ) const
buffer.open( QIODevice::ReadOnly );

QImageReader reader( &buffer );
// if QImageReader::size works, then it's more efficient as it doesn't
// read the whole image (see Qt docs)
const QSize s = reader.size();
if ( s.isValid() )
return s;
QImage im = reader.read();
return im.isNull() ? QSize() : im.size();
}
Expand Down

0 comments on commit 7a5f553

Please sign in to comment.