mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Merge pull request #1013 from tastytea/smaller-thumbnails
Don't send thumbnails that are larger than the original
This commit is contained in:
commit
83738a61b6
1 changed files with 39 additions and 31 deletions
|
@ -896,11 +896,18 @@ MediaUpload::startUpload()
|
|||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
thumbnail_.save(&buffer, "PNG");
|
||||
thumbnail_.save(&buffer, "PNG", 0);
|
||||
if (ba.size() >= (data.size() - data.size() / 10)) {
|
||||
nhlog::ui()->info(
|
||||
"Thumbnail is not a lot smaller than original image, not uploading it");
|
||||
nhlog::ui()->debug(
|
||||
"\n Image size: {:9d}\nThumbnail size: {:9d}", data.size(), ba.size());
|
||||
} else {
|
||||
auto payload = std::string(ba.data(), ba.size());
|
||||
if (encrypt_) {
|
||||
mtx::crypto::BinaryBuf buf;
|
||||
std::tie(buf, thumbnailEncryptedFile) = mtx::crypto::encrypt_file(std::move(payload));
|
||||
std::tie(buf, thumbnailEncryptedFile) =
|
||||
mtx::crypto::encrypt_file(std::move(payload));
|
||||
payload = mtx::crypto::to_string(buf);
|
||||
}
|
||||
thumbnailSize_ = payload.size();
|
||||
|
@ -930,6 +937,7 @@ MediaUpload::startUpload()
|
|||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto payload = std::string(data.data(), data.size());
|
||||
if (encrypt_) {
|
||||
|
|
Loading…
Reference in a new issue