Skip to content

Commit 4d854ee

Browse files
committed
Don't add extraneous metadata padding
If the metadata field is already aligned to a 16-byte boundary then don't add a additional padding. This allows the user to create a 16-byte aligned extension padded with 0x20 that can be read by the Jim software (which doesn't like finding 0x00 in the metadata chunk).
1 parent ee4ce2a commit 4d854ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

nibabel/nifti1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ def get_sizeondisk(self):
334334
size = len(self._mangle(self._content))
335335
size += 8
336336
# extensions size has to be a multiple of 16 bytes
337-
size += 16 - (size % 16)
337+
if size % 16 != 0:
338+
size += 16 - (size % 16)
338339
return size
339340

340341
def __repr__(self):

0 commit comments

Comments
 (0)