Fix image data URI

Make JPEG images use the image/jpeg mimetype instead of the wrong image/png one.
This commit is contained in:
David Gerber 2024-09-01 22:51:22 +02:00 committed by GitHub
parent 64f4d84e74
commit bb4b8f0bc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -274,7 +274,9 @@ bool ImageUtil::optimizeSizeHtml(QString &html, const QImage& original, QImage &
if(optimizeSizeBytes(bytearray, original, optimized,has_transparency?"PNG":"JPG",maxPixels, maxBytes)) if(optimizeSizeBytes(bytearray, original, optimized,has_transparency?"PNG":"JPG",maxPixels, maxBytes))
{ {
QByteArray encodedByteArray = bytearray.toBase64(); QByteArray encodedByteArray = bytearray.toBase64();
html = "<img src=\"data:image/png;base64,"; html = "<img src=\"data:image/";
html.append(has_transparency ? "png" : "jpeg");
html.append(";base64,");
html.append(encodedByteArray); html.append(encodedByteArray);
html.append("\">"); html.append("\">");
return true; return true;