cropng: skip rewriting images if there's nothing to crop.

This commit is contained in:
Marisa the Magician 2025-03-30 13:47:26 +02:00
commit 6c04fcaa54

View file

@ -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<croph; cy++ )
{
uint32_t ccy = cy+cropy;