Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Image Plugin] Fix MIME type and encoding #6

Merged
merged 3 commits into from
Jun 20, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions generic/imageplugin/imageplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,13 @@ void ImagePlugin::actionActivated()
}

QByteArray image;
QString mimeType("jpeg");
if(pix.height() > MAX_SIZE || pix.width() > MAX_SIZE) {
pix = pix.scaled(MAX_SIZE, MAX_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
QBuffer b(&image);
pix.save(&b, "jpg");
QString imageBase64(QUrl::toPercentEncoding(image.toBase64()));
pix.save(&b, mimeType.toLatin1().constData());
QString imageBase64(image.toBase64());
int length = image.length();
if(length > 61440) {
QMessageBox::information(0, tr("The image size is too large."),
Expand All @@ -290,13 +291,13 @@ void ImagePlugin::actionActivated()
.arg(jidToSend)
.arg(stanzaSender->uniqueId(account))
.arg(body)
.arg(fileName.right(fileName.length() - fileName.lastIndexOf(".") - 1))
.arg(mimeType)
.arg(imageBase64);

stanzaSender->sendStanza(account, msgHtml);
psiController->appendSysMsg(account, jidToSend, tr("Image %1 sent <br/><img src=\"data:image/%2;base64,%3\" alt=\"img\"/> ")
.arg(imageName)
.arg(fileName.right(fileName.length() - fileName.lastIndexOf(".") - 1))
.arg(mimeType)
.arg(imageBase64));


Expand Down