Commit b575ecf8 for libheif
commit b575ecf8b8e4422d0ba8d0b0bbc6f35d778b3a5d
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Tue Feb 24 16:01:48 2026 +0100
fix encoding single-tile grids and decoding individual tiles with new size check
diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc
index 533540d0..16ff8d6b 100644
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -1170,22 +1170,13 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
std::cout << "encoding tiled image, tile size: " << tiling.tile_width << "x" << tiling.tile_height
<< " image size: " << tiling.image_width << "x" << tiling.image_height << "\n";
- int tile_width = 0, tile_height = 0;
+ int tile_width = tiling.tile_width;
+ int tile_height = tiling.tile_height;
for (uint32_t ty = 0; ty < tile_generator->nRows(); ty++)
for (uint32_t tx = 0; tx < tile_generator->nColumns(); tx++) {
InputImage input_image = tile_generator->get_image(tx,ty, output_bit_depth);
- if (tile_width == 0) {
- tile_width = heif_image_get_primary_width(input_image.image.get());
- tile_height = heif_image_get_primary_height(input_image.image.get());
-
- if (tile_width <= 0 || tile_height <= 0) {
- std::cerr << "Could not read input image size correctly\n";
- return nullptr;
- }
- }
-
heif_error error;
error = heif_image_extend_to_size_fill_with_zero(input_image.image.get(), tile_width, tile_height);
if (error.code) {
diff --git a/libheif/context.cc b/libheif/context.cc
index e12c43be..fdc7fe7b 100644
--- a/libheif/context.cc
+++ b/libheif/context.cc
@@ -1342,7 +1342,7 @@ Result<std::shared_ptr<HeifPixelImage>> HeifContext::decode_image(heif_item_id I
// --- check that the decoded image has the claimed size (only check if transformations are applied)
- if (!options.ignore_transformations) {
+ if (!options.ignore_transformations && !decode_only_tile) {
uint32_t primary_component = img->get_primary_component();
if (imgitem->get_width() != img->get_width(primary_component) ||