#!/bin/sh ## ## SCRIPT: sho_base64_data_from_imgfile.sh ## ## PURPOSE: Applies the 'base64' command to the input ## (image) filename and shows the resulting text ## in a popup GUI text-editor or text-browser window. ## ## INPUT: a single filename (may be fully-qualified) ## ## CALLED BY: Tk script 'make_BASE64data_fromTkPhotoIMAGEfile.tk' ## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 2013aug14 ## Changed by: Blaise Montandon 2021aug21 Add ability to make the output ## filename based on the input ## filename. ##+################################################################### ##+############################################ ## Remove the directory name from the filename. ##+############################################ RELFILENAME=`basename $1` ##+######################################################## ## Get the 'midname' of the filename by removing the ## extension --- such as '.png' or '.gif'. ## Assumes one dot (.) in the filename, at the extension. ##+######################################################## # FILENAMECROP=`echo "$RELFILENAME" | sed 's|\..*$||'` FILENAMECROP=`echo "$RELFILENAME" | cut -d\. -f1` ##+########################################### ## Make a filename for the base64 output file. ##+########################################### OUTFILE="/tmp/${FILENAMECROP}_base64.txt" ##+################################################ ## If a file by that name already exists, delete it. ## (The user is probably re-making the file.) ##+################################################ if test -f "$OUTFILE" then rm -f "$OUTFILE" fi ##+################################################ ## Use the 'base64' command to make the output file. ##+################################################ base64 "$1" > "$OUTFILE" ##+################################################ ## Show the output file, with a text-file editor ## or a text-file browser. ##+################################################ # TXTBROWSER="/usr/bin/gedit" # TXTBROWSER="/usr/bin/kedit" # TXTBROWSER="/usr/bin/kate" # TXTBROWSER="$HOME/apps/bin/xpg" # TXTBROWSER="$HOME/apps/xpg/xpg" # TXTBROWSER="$HOME/apps/gscite2-27/SciTE" TXTBROWSER="$HOME/apps/gscite_2.27/SciTE" $TXTBROWSER "$OUTFILE" &