Skip to content

Commit

Permalink
Rearranged image settings
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 8, 2025
1 parent 348e6cd commit 2400361
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
return NULL;
}

image->colorPrimaries = AVIF_COLOR_PRIMARIES_UNSPECIFIED;
image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601;

// Validate canvas dimensions
if (width <= 0 || height <= 0) {
PyErr_SetString(PyExc_ValueError, "invalid canvas dimensions");
Expand Down Expand Up @@ -412,10 +408,15 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
PyObject_Del(self);
return NULL;
}
// colorPrimaries and transferCharacteristics are ignored when an ICC
// profile is present, so set them to UNSPECIFIED.
image->colorPrimaries = AVIF_COLOR_PRIMARIES_UNSPECIFIED;
image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
} else {
image->colorPrimaries = AVIF_COLOR_PRIMARIES_BT709;
image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB;
}
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601;

size = PyBytes_GET_SIZE(exif_bytes);
if (size) {
Expand Down

0 comments on commit 2400361

Please sign in to comment.