diff --git a/README.md b/README.md index 8e1840234a..2da93f0104 100644 --- a/README.md +++ b/README.md @@ -305,7 +305,7 @@ This is `libheif` running in JavaScript in your browser. ## Example programs Some example programs are provided in the `examples` directory. -The program `heif-convert` converts all images stored in an HEIF/AVIF file to JPEG or PNG. +The program `heif-dec` converts all images stored in an HEIF/AVIF file to JPEG or PNG. `heif-enc` lets you convert JPEG files to HEIF/AVIF. The program `heif-info` is a simple, minimal decoder that dumps the file structure to the console. @@ -313,7 +313,7 @@ For example convert `example.heic` to JPEGs and one of the JPEGs back to HEIF: ```sh cd examples/ -./heif-convert example.heic example.jpeg +./heif-dec example.heic example.jpeg ./heif-enc example-1.jpeg -o example.heif ``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 320124e96a..059606c7c6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,18 +19,25 @@ install(TARGETS heif-info RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES heif-info.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) -add_executable(heif-convert ${getopt_sources} +add_executable(heif-dec ${getopt_sources} encoder.cc encoder.h encoder_y4m.cc encoder_y4m.h - heif_convert.cc + heif_dec.cc ../libheif/exif.cc common.cc common.h) -target_link_libraries(heif-convert PRIVATE heif) -install(TARGETS heif-convert RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES heif-convert.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +target_link_libraries(heif-dec PRIVATE heif) +install(TARGETS heif-dec RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES heif-dec.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + +# create symbolic link from the old name `heif-convert` to `heif-dec` +if(NOT WIN32) + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/heif-dec${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/heif-convert${CMAKE_EXECUTABLE_SUFFIX})") +else() + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/heif-dec${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/heif-convert${CMAKE_EXECUTABLE_SUFFIX})") +endif() add_executable(heif-enc ${getopt_sources} @@ -82,10 +89,10 @@ int main() { add_definitions(-DHAVE_JPEG_WRITE_ICC_PROFILE=1) endif () - target_link_libraries(heif-convert PRIVATE JPEG::JPEG) + target_link_libraries(heif-dec PRIVATE JPEG::JPEG) target_link_libraries(heif-enc PRIVATE JPEG::JPEG) - target_sources(heif-convert PRIVATE encoder_jpeg.cc encoder_jpeg.h) + target_sources(heif-dec PRIVATE encoder_jpeg.cc encoder_jpeg.h) target_sources(heif-enc PRIVATE decoder.h decoder_jpeg.cc decoder_jpeg.h) endif () @@ -94,10 +101,10 @@ find_package(PNG) if (TARGET PNG::PNG) add_definitions(-DHAVE_LIBPNG=1) - target_link_libraries(heif-convert PRIVATE PNG::PNG) + target_link_libraries(heif-dec PRIVATE PNG::PNG) target_link_libraries(heif-enc PRIVATE PNG::PNG) - target_sources(heif-convert PRIVATE encoder_png.cc encoder_png.h) + target_sources(heif-dec PRIVATE encoder_png.cc encoder_png.h) target_sources(heif-enc PRIVATE decoder_png.cc decoder_png.h) add_executable(heif-thumbnailer ${getopt_sources} diff --git a/examples/heif-convert.1 b/examples/heif-dec.1 similarity index 92% rename from examples/heif-convert.1 rename to examples/heif-dec.1 index 5dc81ca898..da55eae503 100644 --- a/examples/heif-convert.1 +++ b/examples/heif-dec.1 @@ -1,13 +1,13 @@ .TH HEIF-CONVERT 1 .SH NAME -heif-convert \- convert HEIC/HEIF image +heif-dec \- decode HEIC/HEIF image .SH SYNOPSIS -.B heif-convert +.B heif-dec [\fB\-q\fR \fIQUALITY\fR] .IR filename .IR output[.jpg|.png|.y4m] .SH DESCRIPTION -.B heif-convert +.B heif-dec Convert HEIC/HEIF image to a different image format. .SH OPTIONS .TP diff --git a/examples/heif_convert.cc b/examples/heif_dec.cc similarity index 99% rename from examples/heif_convert.cc rename to examples/heif_dec.cc index 0e0e0fff15..eaff6e79fc 100644 --- a/examples/heif_convert.cc +++ b/examples/heif_dec.cc @@ -69,9 +69,9 @@ static void show_help(const char* argv0) { - std::cerr << " heif-convert libheif version: " << heif_get_version() << "\n" - << "-------------------------------------------\n" - "Usage: heif-convert [options] [output-image]\n" + std::cerr << " " << argv0 << " libheif version: " << heif_get_version() << "\n" + << "---------------------------------------\n" + "Usage: " << argv0 << " [options] [output-image]\n" "\n" "The program determines the output file format from the output filename suffix.\n" "These suffixes are recognized: jpg, jpeg, png, y4m. If no output filename is specified, 'jpg' is used.\n" diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh index f28e753055..b2a5b267e5 100755 --- a/scripts/run-ci.sh +++ b/scripts/run-ci.sh @@ -163,19 +163,19 @@ if [ -z "$EMSCRIPTEN_VERSION" ] && [ -z "$CHECK_LICENSES" ] && [ -z "$TARBALL" ] ${BIN_WRAPPER} ./examples/heif-enc${BIN_SUFFIX} --list-encoders echo "List available decoders" - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} --list-decoders + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} --list-decoders echo "Dumping information of sample file ..." ${BIN_WRAPPER} ./examples/heif-info${BIN_SUFFIX} --dump-boxes examples/example.heic if [ ! -z "$WITH_GRAPHICS" ] && [ ! -z "$WITH_HEIF_DECODER" ]; then echo "Converting sample HEIF file to JPEG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} examples/example.heic example.jpg + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} examples/example.heic example.jpg echo "Checking first generated file ..." [ -s "example-1.jpg" ] || exit 1 echo "Checking second generated file ..." [ -s "example-2.jpg" ] || exit 1 echo "Converting sample HEIF file to PNG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} examples/example.heic example.png + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} examples/example.heic example.png echo "Checking first generated file ..." [ -s "example-1.png" ] || exit 1 echo "Checking second generated file ..." @@ -183,11 +183,11 @@ if [ -z "$EMSCRIPTEN_VERSION" ] && [ -z "$CHECK_LICENSES" ] && [ -z "$TARBALL" ] fi if [ ! -z "$WITH_GRAPHICS" ] && [ ! -z "$WITH_AVIF_DECODER" ]; then echo "Converting sample AVIF file to JPEG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} examples/example.avif example.jpg + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} examples/example.avif example.jpg echo "Checking generated file ..." [ -s "example.jpg" ] || exit 1 echo "Converting sample AVIF file to PNG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} examples/example.avif example.png + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} examples/example.avif example.png echo "Checking generated file ..." [ -s "example.png" ] || exit 1 fi @@ -197,14 +197,14 @@ if [ -z "$EMSCRIPTEN_VERSION" ] && [ -z "$CHECK_LICENSES" ] && [ -z "$TARBALL" ] echo "Checking generated file ..." [ -s "output-single.heic" ] || exit 1 echo "Converting back generated heif to JPEG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} output-single.heic output-single.jpg + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} output-single.heic output-single.jpg echo "Checking generated file ..." [ -s "output-single.jpg" ] || exit 1 echo "Converting multiple JPEG files to heif ..." ${BIN_WRAPPER} ./examples/heif-enc${BIN_SUFFIX} -o output-multi.heic --verbose --verbose --verbose --thumb 320x240 example-1.jpg example-2.jpg echo "Checking generated file ..." [ -s "output-multi.heic" ] || exit 1 - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} output-multi.heic output-multi.jpg + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} output-multi.heic output-multi.jpg echo "Checking first generated file ..." [ -s "output-multi-1.jpg" ] || exit 1 echo "Checking second generated file ..." @@ -216,7 +216,7 @@ if [ -z "$EMSCRIPTEN_VERSION" ] && [ -z "$CHECK_LICENSES" ] && [ -z "$TARBALL" ] echo "Checking generated file ..." [ -s "output-jpeg.avif" ] || exit 1 echo "Converting back generated AVIF to JPEG ..." - ${BIN_WRAPPER} ./examples/heif-convert${BIN_SUFFIX} output-jpeg.avif output-jpeg.jpg + ${BIN_WRAPPER} ./examples/heif-dec${BIN_SUFFIX} output-jpeg.avif output-jpeg.jpg echo "Checking generated file ..." [ -s "output-jpeg.jpg" ] || exit 1 fi