From ee478072c8489e145ea615cc11067485da477d25 Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 10 Jul 2023 14:42:09 +0800 Subject: [PATCH] ENH:image to base64&supports uppercase file names the issue occurs when trying to convert an image with uppercase file names to base64 format. Change-Id: I1b3b4b95ae5602affc7c2d7c584fdc459d90ee0d --- src/slic3r/GUI/Project.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index 73e99222a..78e120c9a 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -324,11 +324,14 @@ std::map> ProjectPanel::Reload(wxString aux_path) pfile_obj["filename"] = wxGetApp().url_encode(file_path_obj.filename().string().c_str()); pfile_obj["size"] = formatBytes((unsigned long)filelen); + std::string file_extension = file_path_obj.extension().string(); + boost::algorithm::to_lower(file_extension); + //image - if (file_path_obj.extension() == ".jpg" || - file_path_obj.extension() == ".jpeg" || - file_path_obj.extension() == ".png" || - file_path_obj.extension() == ".bmp") + if (file_extension == ".jpg" || + file_extension == ".jpeg" || + file_extension == ".png" || + file_extension == ".bmp") { wxString base64_str = to_base64(file_path); @@ -363,7 +366,9 @@ wxString ProjectPanel::to_base64(std::string file_path) base64_format[".png"] = wxBITMAP_TYPE_PNG; base64_format[".bmp"] = wxBITMAP_TYPE_BMP; + std::string extension = file_path.substr(file_path.rfind("."), file_path.length()); + boost::algorithm::to_lower(extension); auto image = new wxImage(encode_path(file_path.c_str())); wxMemoryOutputStream mem;