From fe9d9d1de82a57e4cdebdad30431423c7662ce50 Mon Sep 17 00:00:00 2001 From: Florian Fieber Date: Thu, 19 Jun 2014 12:55:24 +0200 Subject: [PATCH] [imageplugin] Fix MIME media type 1. The file extension might not be the correct MIME type, and is empty for images extracted from the clipboard 2. The image is converted to a JPEG, anyway --- generic/imageplugin/imageplugin.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generic/imageplugin/imageplugin.cpp b/generic/imageplugin/imageplugin.cpp index 2b1f7f02..737c98dd 100644 --- a/generic/imageplugin/imageplugin.cpp +++ b/generic/imageplugin/imageplugin.cpp @@ -267,11 +267,12 @@ 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"); + pix.save(&b, mimeType.toAscii().constData()); QString imageBase64(QUrl::toPercentEncoding(image.toBase64())); int length = image.length(); if(length > 61440) { @@ -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
\"img\"/ ") .arg(imageName) - .arg(fileName.right(fileName.length() - fileName.lastIndexOf(".") - 1)) + .arg(mimeType) .arg(imageBase64));