From c75b76ddf5738dd6128edd79e53fcc4ad40cd5bc Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 2 Aug 2022 01:02:30 +0200 Subject: [PATCH] cellPhotoImport: fallback to extension if sub_type is unknown --- rpcs3/Emu/Cell/Modules/cellPhotoImport.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellPhotoImport.cpp b/rpcs3/Emu/Cell/Modules/cellPhotoImport.cpp index a58c8df0b7..c8ff17e10e 100644 --- a/rpcs3/Emu/Cell/Modules/cellPhotoImport.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPhotoImport.cpp @@ -175,8 +175,8 @@ error_code select_photo(std::string dst_dir) const std::string filename = info.path.substr(info.path.find_last_of(fs::delim) + 1); const std::string title = info.get_metadata("title", filename); - const std::string sub_type = fmt::to_lower(info.sub_type); const std::string dst_path = dst_dir + "/" + filename; + std::string sub_type = info.sub_type; strcpy_trunc(g_filedata->dstFileName, filename); strcpy_trunc(g_filedata->photo_title, title); @@ -187,6 +187,20 @@ error_code select_photo(std::string dst_dir) g_filedata->data_sub->width = info.width; g_filedata->data_sub->height = info.height; + cellPhotoImportUtil.notice("Raw image data: filename='%s', title='%s', game='%s', sub_type='%s', width=%d, height=%d, orientation=%d ", + filename, title, Emu.GetTitle(), sub_type, info.width, info.height, info.orientation); + + // Fallback to extension if necessary + if (sub_type.empty()) + { + sub_type = get_file_extension(filename); + } + + if (!sub_type.empty()) + { + sub_type = fmt::to_lower(sub_type); + } + if (sub_type == "jpg" || sub_type == "jpeg") { g_filedata->data_sub->format = CELL_PHOTO_IMPORT_FT_JPEG; @@ -234,7 +248,7 @@ error_code select_photo(std::string dst_dir) break; } - cellPhotoImportUtil.notice("Media list dialog: selected entry '%s'. Copying to '%s'...", info.path, dst_path); + cellPhotoImportUtil.notice("Media list dialog: Copying '%s' to '%s'...", info.path, dst_path); if (!fs::copy_file(info.path, dst_path, false)) { @@ -242,9 +256,6 @@ error_code select_photo(std::string dst_dir) result = CELL_PHOTO_IMPORT_ERROR_COPY; } - cellPhotoImportUtil.notice("Raw image data: filename='%s', title='%s', game='%s', sub_type='%s', width=%d, height=%d, orientation=%d ", - filename, title, Emu.GetTitle(), sub_type, info.width, info.height, info.orientation); - cellPhotoImportUtil.notice("Cell image data: dstFileName='%s', photo_title='%s', game_title='%s', format=%d, width=%d, height=%d, rotate=%d ", g_filedata->dstFileName, g_filedata->photo_title, g_filedata->game_title, static_cast(g_filedata->data_sub->format), g_filedata->data_sub->width, g_filedata->data_sub->height, static_cast(g_filedata->data_sub->rotate)); }