Output: validate image format before rendering
This commit is contained in:
1 parent
d5d21c7659
commit
4aa5f6666a
1 file changed
+18
+18
@@ -101,6 +101,21 @@ static int parse_moffat_beta(const char *text, double *value) {
|
|||||||
return errno || *end || *value <= 1.0 ? -1 : 0;
|
return errno || *end || *value <= 1.0 ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int validate_tonemapped_output_path(const char *path) {
|
||||||
|
const size_t path_length = strlen(path);
|
||||||
|
#ifdef ENABLE_PNG
|
||||||
|
if (path_length >= 4 && strcmp(path + path_length - 4, ".png") == 0)
|
||||||
|
return 0;
|
||||||
|
fputs("PNG output is enabled; use a .png output path.\n", stderr);
|
||||||
|
#else
|
||||||
|
if (path_length >= 4 && strcmp(path + path_length - 4, ".ppm") == 0)
|
||||||
|
return 0;
|
||||||
|
fputs("PNG output is unavailable; use a .ppm output path or rebuild with libpng.\n",
|
||||||
|
stderr);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_args(int argc, char **argv, Settings *s,
|
static int parse_args(int argc, char **argv, Settings *s,
|
||||||
const char **write_path) {
|
const char **write_path) {
|
||||||
#ifdef ENABLE_PNG
|
#ifdef ENABLE_PNG
|
||||||
@@ -505,6 +520,9 @@ int main(int argc, char **argv) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (settings.frames_dir == NULL &&
|
||||||
|
validate_tonemapped_output_path(settings.output_path))
|
||||||
|
return 2;
|
||||||
StarCatalog catalog = {0};
|
StarCatalog catalog = {0};
|
||||||
if (settings.all_sky_catalog_path != NULL) {
|
if (settings.all_sky_catalog_path != NULL) {
|
||||||
if (catalog_load_all_sky(&catalog, settings.all_sky_catalog_path)) {
|
if (catalog_load_all_sky(&catalog, settings.all_sky_catalog_path)) {
|
||||||
|
|||||||
Reference in new issue
Block a user