Skip to content

Commit

Permalink
Merge pull request #1107 from bradh/issue1101
Browse files Browse the repository at this point in the history
examples: allow heif-enc to show params without needing input file
  • Loading branch information
farindk authored Jun 11, 2024
2 parents 4944d7d + 186371e commit 0b71dd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/heif-enc.1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Output filename (optional).
Enable logging output (more will increase logging level).
.TP
.BR \-P ", "\-\-params\fR
Show all encoder parameters.
Show all encoder parameters and exit. Input file is not required or used.
.TP
.BR \-b\fR\ \fIDEPTH\fR
Bit-depth of generated HEIF file when using 16-bit PNG input (default: 10 bit).
Expand Down
32 changes: 15 additions & 17 deletions examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void show_help(const char* argv0)
<< " --no-thumb-alpha do not save alpha channel in thumbnail image\n"
<< " -o, --output output filename (optional)\n"
<< " --verbose enable logging output (more will increase logging level)\n"
<< " -P, --params show all encoder parameters\n"
<< " -P, --params show all encoder parameters and exit, input file not required or used.\n"
<< " -b, --bit-depth # bit-depth of generated HEIF/AVIF file when using 16-bit PNG input (default: 10 bit)\n"
<< " -p set encoder parameter (NAME=VALUE)\n"
<< " -A, --avif encode as AVIF (not needed if output filename with .avif suffix is provided)\n"
Expand Down Expand Up @@ -626,22 +626,6 @@ int main(int argc, char** argv)
return 0;
}

if (optind > argc - 1) {
show_help(argv[0]);
return 0;
}


// If we were given a list of filenames and no '-o' option, check whether the last filename is the desired output filename.

if (output_filename.empty() && argc>1) {
if (guess_compression_format_from_filename(argv[argc-1]) != heif_compression_undefined) {
output_filename = argv[argc-1];
argc--;
}
}


// --- determine output compression format (from output filename or command line parameter)

heif_compression_format compressionFormat;
Expand Down Expand Up @@ -720,6 +704,20 @@ int main(int argc, char** argv)
return 0;
}

if (optind > argc - 1) {
show_help(argv[0]);
return 0;
}


// If we were given a list of filenames and no '-o' option, check whether the last filename is the desired output filename.

if (output_filename.empty() && argc>1) {
if (guess_compression_format_from_filename(argv[argc-1]) != heif_compression_undefined) {
output_filename = argv[argc-1];
argc--;
}
}

struct heif_error error;

Expand Down

0 comments on commit 0b71dd3

Please sign in to comment.