| 657 | } |
| 658 | |
| 659 | QString ClientInterface::getMediaTypeForImage(const QString &filePath) const |
| 660 | { |
| 661 | static const QHash<QString, QString> mediaTypes |
| 662 | = {{"png", "image/png"}, |
| 663 | {"jpg", "image/jpeg"}, |
| 664 | {"jpeg", "image/jpeg"}, |
| 665 | {"gif", "image/gif"}, |
| 666 | {"webp", "image/webp"}, |
| 667 | {"bmp", "image/bmp"}, |
| 668 | {"svg", "image/svg+xml"}}; |
| 669 | |
| 670 | QFileInfo fileInfo(filePath); |
| 671 | QString extension = fileInfo.suffix().toLower(); |
| 672 | |
| 673 | if (mediaTypes.contains(extension)) { |
| 674 | return mediaTypes[extension]; |
| 675 | } |
| 676 | |
| 677 | QMimeDatabase mimeDb; |
| 678 | QMimeType mimeType = mimeDb.mimeTypeForFile(filePath); |
| 679 | return mimeType.name(); |
| 680 | } |
| 681 | |
| 682 | QString ClientInterface::encodeImageToBase64(const QString &filePath) const |
| 683 | { |