Commit f55e39808 for imagemagick.org
commit f55e39808e1ef004358dbbfc4a276874ed4b73cc
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Sun Jul 26 09:31:24 2026 +0200
Write the x and y offset in the tga encoder when the value fit in the unsigned short range.
diff --git a/coders/tga.c b/coders/tga.c
index 324cdf9fa..759a0cfa4 100644
--- a/coders/tga.c
+++ b/coders/tga.c
@@ -882,7 +882,11 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,Image *image,
tga_info.colormap_length=0;
tga_info.colormap_size=0;
tga_info.x_origin=0;
+ if ((image->page.x > 0) && (image->page.x <= MAGICK_USHORT_MAX))
+ tga_info.x_origin=(unsigned short) image->page.x;
tga_info.y_origin=0;
+ if ((image->page.y > 0) && (image->page.y <= MAGICK_USHORT_MAX))
+ tga_info.y_origin=(unsigned short) image->page.y;
tga_info.width=(unsigned short) image->columns;
tga_info.height=(unsigned short) image->rows;
tga_info.bits_per_pixel=8;