Reputation: 35
i'm stuck with a very bizarre problem with 'convert.exe' which I'm not able to tackle.
Preparation: I copy a .jpg image to the local users temp-path. I then try to rotate it by 90 degrees. In my code, the first attempt always fails. Any subsequent call to rotate always succeeds.
Here is the code in question:
proc rotateImage { imagePathFile { degrees 90} } {
set convert_command "convert.exe"
try {
set file_extension [file extension $imagePathFile]
if {$file_extension eq ".jpg"} {
exec $convert_command $imagePathFile -rotate $degrees -strip -quality 85 -sampling-factor 4:2:0 $imagePathFile
} elseif {$file_extension eq ".tif"} {
exec $convert_command $imagePathFile -rotate $degrees -compress Group4 $imagePathFile
}
} on error {msg} { ; tk_messageBox -message "convert.exe not available." ; return -1 ; }
}
Additinal Info: Whenever I copy the file in question beforehand, like with a little delay, the rotation always works. Nevertheless, the file is completely copied, when I called the code regularly, the copy process was finished. And to fire this even more: If I call the 'exec' unconditionally before the try, it also always works (which takes the ability to distinguish between .tif and .jpg and some proper error handling).
Its the strangest effect in TCL I've encountered so far and I have not the faintest idea, what is going on :)
Has anyone any idea, what causes this strange behaviour and how to prevent it?
Upvotes: 1
Views: 64