@@ -373,39 +373,53 @@ int main(int argc, char** argv)
373
373
return EXIT_FAILURE;
374
374
}
375
375
376
+ std::string fileExtension = vtksys::SystemTools::GetFilenameLastExtension (inputFileName);
377
+ bool headerOnlyUpdatePossible = (inputFileName == outputFileName) // file overwrite requested
378
+ && (igsioCommon::IsEqualInsensitive (fileExtension, " .mhd" ) || igsioCommon::IsEqualInsensitive (fileExtension, " .nhdr" ))
379
+ && !useCompression; // hard to carry over compressed data size
380
+ bool headerOnlyOperation = false ; // false by default
381
+
376
382
// Set operation
377
383
if (strOperation.empty ())
378
384
{
379
385
operation = NO_OPERATION;
380
386
LOG_INFO (" No modification operation has been specified (specify --operation parameter to change the input sequence)." );
387
+ headerOnlyOperation = true ;
381
388
}
382
389
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FRAME_FIELD_NAME" ))
383
390
{
384
391
operation = UPDATE_FRAME_FIELD_NAME;
392
+ headerOnlyOperation = true ;
385
393
}
386
394
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FRAME_FIELD_VALUE" ))
387
395
{
388
396
operation = UPDATE_FRAME_FIELD_VALUE;
397
+ headerOnlyOperation = true ;
389
398
}
390
399
else if (igsioCommon::IsEqualInsensitive (strOperation, " DELETE_FRAME_FIELD" ))
391
400
{
392
401
operation = DELETE_FRAME_FIELD;
402
+ headerOnlyOperation = true ;
393
403
}
394
404
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FIELD_NAME" ))
395
405
{
396
406
operation = UPDATE_FIELD_NAME;
407
+ headerOnlyOperation = true ;
397
408
}
398
409
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FIELD_VALUE" ))
399
410
{
400
411
operation = UPDATE_FIELD_VALUE;
412
+ headerOnlyOperation = true ;
401
413
}
402
414
else if (igsioCommon::IsEqualInsensitive (strOperation, " DELETE_FIELD" ))
403
415
{
404
416
operation = DELETE_FIELD;
417
+ headerOnlyOperation = true ;
405
418
}
406
419
else if (igsioCommon::IsEqualInsensitive (strOperation, " ADD_TRANSFORM" ))
407
420
{
408
421
operation = ADD_TRANSFORM;
422
+ headerOnlyOperation = true ;
409
423
}
410
424
else if (igsioCommon::IsEqualInsensitive (strOperation, " TRIM" ))
411
425
{
@@ -780,7 +794,8 @@ int main(int argc, char** argv)
780
794
// Save output file to file
781
795
782
796
LOG_INFO (" Save output sequence file to: " << outputFileName);
783
- if (vtkPlusSequenceIO::Write (outputFileName, trackedFrameList, trackedFrameList->GetImageOrientation (), useCompression, operation != REMOVE_IMAGE_DATA) != PLUS_SUCCESS)
797
+ if (vtkPlusSequenceIO::Write (outputFileName, trackedFrameList, trackedFrameList->GetImageOrientation (),
798
+ useCompression, operation == REMOVE_IMAGE_DATA, headerOnlyUpdatePossible && headerOnlyOperation) != PLUS_SUCCESS)
784
799
{
785
800
LOG_ERROR (" Couldn't write sequence file: " << outputFileName);
786
801
return EXIT_FAILURE;
0 commit comments