Skip to content

Commit fbf9db1

Browse files
committed
gpujpegtool: avoid some error on unknown extension
if user specifies all image properties, like in the following: gpujpegtool -s 1920x1080 -c rgb -f 4444-u8-p0123 \ -O enc_opt_channel_remap=2103 -e in.gbra out.jpg do not query the format from the file which avoids the error: [GPUJPEG] [Error] GPUJPEG_IMAGE_FILE_UNKNOWN should not be passed! because of the file extension .gbra, which is now semantically perfectly correct.
1 parent 23bd3df commit fbf9db1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ adjust_params(struct gpujpeg_parameters* param, struct gpujpeg_image_parameters*
251251
// if possible, read properties from file
252252
struct gpujpeg_image_parameters file_param_image = gpujpeg_default_image_parameters();
253253
const char *raw_file = encode ? in : out;
254-
gpujpeg_image_get_properties(raw_file, &file_param_image, encode);
254+
if ( param_image->width == 0 || param_image->height == 0 || param_image->pixel_format == GPUJPEG_PIXFMT_NONE ||
255+
param_image->color_space == GPUJPEG_NONE ) {
256+
gpujpeg_image_get_properties(raw_file, &file_param_image, encode);
257+
}
255258
param_image->width = USE_IF_NOT_NULL_ELSE(param_image->width, file_param_image.width);
256259
param_image->height = USE_IF_NOT_NULL_ELSE(param_image->height, file_param_image.height);
257260
if ( param_image->color_space == GPUJPEG_NONE ) {

0 commit comments

Comments
 (0)