Skip to content
Snippets Groups Projects
Commit ed3f5861 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

profile-send: center crop profile pic before scaling a compressing

Change-Id: I07633e7e1d6b689af30b38648d6c2d354cf2c029
parent bbda1066
Branches
No related tags found
No related merge requests found
......@@ -159,7 +159,10 @@ compressedAvatar(const QString& image)
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
qimage.scaled({128, 128}).save(&buffer, "JPEG", 90);
auto size = qMin(qimage.width(), qimage.height());
auto rect = QRect((qimage.width() - size) / 2, (qimage.height() - size) / 2, size, size);
qimage.copy(rect).scaled({size, size}, Qt::KeepAspectRatio).save(&buffer, "JPEG", 90);
auto b64Img = bArray.toBase64().trimmed();
return QString::fromLocal8Bit(b64Img.constData(), b64Img.length());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment