Fixed resize bug

This commit is contained in:
hunbernd 2017-11-05 18:58:07 +01:00
parent cd5eb5cb77
commit 5d03ceb360

View File

@ -64,9 +64,10 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti
//Downscale the image to fit into maxPixels
double whratio = (qreal)original.width() / (qreal)original.height();
int maxwidth;
if(maxPixels > 0)
maxwidth = (int)sqrt((double)(maxPixels) * whratio);
else
if(maxPixels > 0) {
int maxwidth2 = (int)sqrt((double)(maxPixels) * whratio);
maxwidth = (original.width() > maxwidth2) ? maxwidth2 : original.width();
} else
maxwidth = original.width();
int minwidth = (int)sqrt(100.0 * whratio);