From 6c04fcaa540521357f5b24c728618c57ae540f36 Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sun, 30 Mar 2025 13:47:26 +0200 Subject: [PATCH] cropng: skip rewriting images if there's nothing to crop. --- cropng.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cropng.c b/cropng.c index 64d8182..5645777 100644 --- a/cropng.c +++ b/cropng.c @@ -286,9 +286,17 @@ void processpic( const char *fname ) if ( trns ) free(trns); return; } - uint8_t *odata = calloc(cropw*croph,pxsize); uint32_t ow = cropw, oh = croph; int32_t ox = x-cropx, oy = y-cropy; + if ( (ow == w) && (oh == h) && (ox == x) && (oy == y) ) + { + printf(" Nothing to crop, skipping.\n"); + free(idata); + if ( plte ) free(plte); + if ( trns ) free(trns); + return; + } + uint8_t *odata = calloc(cropw*croph,pxsize); for ( uint32_t cy=0; cy