I tried to convert jpg to heic with ispe of grid.
I used heif-enc in Ubuntu, like below.
heif-enc -o output.heic input.jpg
It is converted without error, but "output.heic" metadata doesn't have ispe(image spatial extent) of grid. It only has ispe of image itself. By heif-enc, it is possible to add thumbnail ispe, but I cannot find way to set ispe of grid.
How can I set ispe of grid as 512x512(usual type)? It is best if there is a way using 'heif-enc' or any things else is ok.
Title: How to set the grid of a HEIF file when converting JPG to HEIC?
Converting JPG images to HEIC (High-Efficiency Image File Format) can significantly reduce file sizes while maintaining image quality. To set the grid of a HEIF file during the conversion process, you can use the
libheiflibrary along withlibjpegto handle the conversion. I'll guide you through the steps to achieve this on a Unix-like system (Linux, macOS) as well as Windows.Step 1: Install necessary libraries and tools
Ensure you have
libheifandlibjpeginstalled on your system:Linux (Ubuntu/Debian):
macOS (Homebrew):
Windows: Download and install precompiled binaries of
libheifandlibjpegfrom their respective official websites. Make sure to include the necessary header files.Step 2: Writing the C code
Create a C program that uses
libheifandlibjpegto perform the conversion and set the grid size.Step 3: Compiling the code
Compile the C code using a C compiler. Make sure to link the required libraries.
Linux/macOS:
Windows (assuming MinGW):
Step 4: Running the converter
Run the converter with the input JPEG file, desired output HEIF file, and the grid size you want to set. For example:
This will convert
input.jpgtooutput.heicwith a grid size of 16. Adjust the grid size according to your preference or requirements.Remember that
libheifis a powerful library that provides many other options for configuring HEIF output. This example focuses on setting the grid size, but you can explore other settings and functionalities offered by the library.Note: Always make sure to respect licensing terms and conditions of the libraries used. Proper error handling and resource management are essential for production code but might have been omitted in this simplified example.