Hi Dana -
The decode command line you posted is correct, so it's most likely the text you're extracting from the database is either corrupted or wasn't encoded as you expect. Note that your success with the img tag decoding may be misleading. I can't give you details that apply to this case, but browsers typically use smarter decoding tools which are more robust than a single command line with fixed options. So unless your target display is in fact a browser, I'm not sure it's useful to try and find out how your browser is making sense of that text file.
1) Was the text in the database produced by an internal encoder or was it obtained either from a standard e-mail attachment or produced by this command or its equivalent?:
openssl enc -base64 -in testscript.tiff -out base64sm.txt
2) Are you sure you're retrieving exactly the same bytes that were stored in the database?
To isolate the problem, you might use the above command to encode a small image file, e.g.:
openssl enc -base64 -in picture.png -out picture.txt
Load picture.txt into your database (as text, without any further processing), and then extract that text as best you can, saving the result in picture2.txt. Then:
diff picture.txt picture2.txt
These files should be identical, so if you get any output from diff, you need to look at how you stored and/or retrieved the bytes to/from the database. If the files are identical, you need to look at how your tiff file was encoded.
Hope that helps!
\- Ray