Bugfix : the image file was not saved if the path or the filename were containing non ASCII chars (seen on Winddows)
This commit is contained in:
parent
632a4b3812
commit
b3f44005bb
@ -19,6 +19,7 @@
|
||||
#include <imagedata.h>
|
||||
#include <iptcpairs.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <safegtk.h>
|
||||
#ifdef RAWZOR_SUPPORT
|
||||
#include <rwz_sdk.h>
|
||||
#endif
|
||||
@ -278,27 +279,6 @@ ImageData::~ImageData () {
|
||||
iptc_data_free (iptc);
|
||||
}
|
||||
|
||||
Glib::ustring safe_locale_to_utf8 (const std::string& src)
|
||||
{
|
||||
Glib::ustring utf8_str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
utf8_str = Glib::locale_to_utf8(src);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
utf8_str = locale_to_utf8(src, error);
|
||||
if (error.get())
|
||||
utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?", error);
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return utf8_str;
|
||||
}
|
||||
|
||||
const std::vector<procparams::IPTCPair> ImageData::getIPTCData () const {
|
||||
|
||||
std::vector<procparams::IPTCPair> iptcc;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <png.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <imageio.h>
|
||||
#include <safegtk.h>
|
||||
#include <tiff.h>
|
||||
#include <tiffio.h>
|
||||
#include <stdio.h>
|
||||
@ -409,7 +410,7 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
|
||||
|
||||
int ImageIO::savePNG (Glib::ustring fname, int compression, int bps) {
|
||||
|
||||
FILE* file=g_fopen(fname.c_str (),"wb");
|
||||
FILE* file=g_fopen(safe_locale_from_utf8(fname).c_str (),"wb");
|
||||
|
||||
if (!file)
|
||||
return IMIO_CANNOTREADFILE;
|
||||
@ -493,7 +494,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality) {
|
||||
cinfo.err = jpeg_std_error (&jerr);
|
||||
jpeg_create_compress (&cinfo);
|
||||
|
||||
FILE *file = g_fopen (fname.c_str (), "wb");
|
||||
FILE *file = g_fopen (safe_locale_from_utf8(fname).c_str (), "wb");
|
||||
|
||||
if (!file)
|
||||
return IMIO_CANNOTREADFILE;
|
||||
@ -597,7 +598,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) {
|
||||
unsigned char* linebuffer = new unsigned char[lineWidth];
|
||||
// TODO the following needs to be looked into - do we really need two ways to write a Tiff file ?
|
||||
if (exifRoot && uncompressed) {
|
||||
FILE *file = g_fopen (fname.c_str (), "wb");
|
||||
FILE *file = g_fopen (safe_locale_from_utf8(fname).c_str (), "wb");
|
||||
|
||||
if (!file)
|
||||
return IMIO_CANNOTREADFILE;
|
||||
|
@ -17,6 +17,7 @@
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <glib/gstdio.h>
|
||||
#include <safegtk.h>
|
||||
#include <procparams.h>
|
||||
#include <glibmm.h>
|
||||
#include <sstream>
|
||||
@ -329,7 +330,7 @@ int ProcParams::save (Glib::ustring fname) const {
|
||||
keyFile.set_string_list ("IPTC", iptc[i].field, values);
|
||||
}
|
||||
|
||||
FILE *f = g_fopen (fname.c_str(), "wt");
|
||||
FILE *f = g_fopen (safe_locale_from_utf8(fname).c_str(), "wt");
|
||||
|
||||
if (f==NULL)
|
||||
return 1;
|
||||
|
@ -208,6 +208,9 @@ rtengine::ProcessingJob* BatchQueue::imageReady (rtengine::IImage16* img) {
|
||||
// the same output filename with different extension
|
||||
//processing->params.save (removeExtension(fname) + paramFileExtension);
|
||||
processing->params.save (fname + paramFileExtension);
|
||||
else {
|
||||
printf("Unable to process or save %s\n", fname.c_str());
|
||||
}
|
||||
if (processing->thumbnail) {
|
||||
processing->thumbnail->imageDeveloped ();
|
||||
processing->thumbnail->imageRemovedFromQueue ();
|
||||
|
@ -117,6 +117,49 @@ void safe_build_subdir_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ust
|
||||
}
|
||||
}
|
||||
|
||||
Glib::ustring safe_locale_to_utf8 (const std::string& src)
|
||||
{
|
||||
Glib::ustring utf8_str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
utf8_str = Glib::locale_to_utf8(src);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
utf8_str = locale_to_utf8(src, error);
|
||||
if (error.get())
|
||||
utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?", error);
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return utf8_str;
|
||||
}
|
||||
|
||||
std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str)
|
||||
{
|
||||
std::string str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
str = Glib::locale_from_utf8(utf8_str);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
//str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
str = Glib::locale_from_utf8(utf8_str, error);
|
||||
/*if (error.get())
|
||||
{str = Glib::convert_with_fallback(utf8_str, "LATIN1", "UTF8", "?", error);}*/
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
|
||||
{
|
||||
std::string cmd;
|
||||
@ -144,24 +187,3 @@ bool safe_spawn_command_line_async (const Glib::ustring& cmd_utf8)
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string safe_locale_from_utf8 (const Glib::ustring& utf8_str)
|
||||
{
|
||||
std::string str;
|
||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
||||
try {
|
||||
str = Glib::locale_from_utf8(utf8_str);
|
||||
}
|
||||
catch (const Glib::ConvertError& e) {
|
||||
//utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?");
|
||||
}
|
||||
#else
|
||||
{
|
||||
std::auto_ptr<Glib::Error> error;
|
||||
str = Glib::locale_from_utf8(utf8_str, error);
|
||||
if (error.get())
|
||||
{/*utf8_str = Glib::convert_with_fallback(src, "UTF8", "LATIN1","?", error);*/}
|
||||
}
|
||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
||||
return str;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user