[bug ?] File exists
Posted: Sun Aug 24, 2008 11:17 pm
NCONVERT seems to expose a suboptimal / inconsistent / "bad" behavior on "file exists" problem: if a file is to be saved and a file of given name already exists.
- When converting a single image, it "silently" kicks the existing file and leaves the new one instead
(YES, I am sensitive to this type of problem, IMHO a BUG
)
- When decomposing an animation and frame files already do exist, it just doesn't save anything and reports success
Suggestion how to fix:
- Consistent behavior for both single image convert and decomposing
- NEVER write to an existing file -> no risk of trouble with "R" attribute
- Before saving, always check whether file exists - if NO, just save, if YES, try to rename (limit amount of attempts to ... 5 maybe) by incrementing 0th character:
BLAH.BMP -> CLAH.BMP -> DLAH.BMP -> ELAH.BMP-> FLAH.BMP -> still exists ? Give up: Impossible to save "BLAH.BMP" , file exists, renaming didn't help
YEAH.PNG -> ZEAH.PNG -> AEAH.PNG -> ...
photo.jpg -> ... (increment lowercase or UCASE or so)
~#.gif -> A#.gif -> B#.gif -> ...
I deliberately suggest using 0th character, not the last one, nor appending anything (like " BLAH(2).BMP " ) ... end of the filename is "used" for frame decomposition
This way one could decompose the same animation multiple times, with different options, and get multiple sets of frames:
WOW.PNG (APNG with 3 frames)
Result: WOW-1.BMP WOW-2.BMP WOW-3.BMP
next attempt:
Result: XOW-1.BMP XOW-2.BMP XOW-3.BMP
and one more:
Result: YOW-1.BMP YOW-2.BMP YOW-3.BMP
Now having 3 x 3 images ready for inspection
- When converting a single image, it "silently" kicks the existing file and leaves the new one instead


- When decomposing an animation and frame files already do exist, it just doesn't save anything and reports success

Suggestion how to fix:
- Consistent behavior for both single image convert and decomposing
- NEVER write to an existing file -> no risk of trouble with "R" attribute

- Before saving, always check whether file exists - if NO, just save, if YES, try to rename (limit amount of attempts to ... 5 maybe) by incrementing 0th character:
BLAH.BMP -> CLAH.BMP -> DLAH.BMP -> ELAH.BMP-> FLAH.BMP -> still exists ? Give up: Impossible to save "BLAH.BMP" , file exists, renaming didn't help
YEAH.PNG -> ZEAH.PNG -> AEAH.PNG -> ...
photo.jpg -> ... (increment lowercase or UCASE or so)
~#.gif -> A#.gif -> B#.gif -> ...
I deliberately suggest using 0th character, not the last one, nor appending anything (like " BLAH(2).BMP " ) ... end of the filename is "used" for frame decomposition

This way one could decompose the same animation multiple times, with different options, and get multiple sets of frames:
WOW.PNG (APNG with 3 frames)
Code: Select all
NC -xall -out bmp WOW.PNG
next attempt:
Code: Select all
NC -xall -out bmp -truecolors WOW.PNG
and one more:
Code: Select all
NC -xall -out bmp -truecolors -gamma 1.2 WOW.PNG
Now having 3 x 3 images ready for inspection
