Skip to content

Commit

Permalink
Merge pull request #996 from strukturag/rename-heif-convert
Browse files Browse the repository at this point in the history
Rename heif-convert to heif-dec (planned for v1.18.0)
  • Loading branch information
farindk authored Jun 26, 2024
2 parents 78f97e3 + a0275c7 commit eb795b8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ 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.
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
```
Expand Down
25 changes: 16 additions & 9 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 ()

Expand All @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions examples/heif-convert.1 → examples/heif-dec.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/heif_convert.cc → examples/heif_dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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] <input-image> [output-image]\n"
std::cerr << " " << argv0 << " libheif version: " << heif_get_version() << "\n"
<< "---------------------------------------\n"
"Usage: " << argv0 << " [options] <input-image> [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"
Expand Down
16 changes: 8 additions & 8 deletions scripts/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,31 @@ 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 ..."
[ -s "example-2.png" ] || exit 1
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
Expand All @@ -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 ..."
Expand All @@ -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
Expand Down

0 comments on commit eb795b8

Please sign in to comment.