SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group
USA

December 2002


Lynx on OS/2: Straight Answers and Keen Tricks

Part 3 - Viewing Images

by Dallas E. Legan

In parts 1 and 2 of this series, we've concentrated on Lynx and getting it working optimally on your OS/2 system. Now it's time to get creative.


How can I view images with Lynx (or other text mode browsers)?

With REXX!

The build of Lynx that you install may handle image viewing conveniently 'out of the box', but frankly I had to fiddle around some to get it working. I had similar experiences with other text mode browsers I use, in particular eLinks. The following script works with Lynx (or other text mode browsers) and an image viewer (I use PMJPEG, hence the name of the script) so that you can view pictures and other graphics on web pages.

This wrapper script combines all the various measures I found necessary to get PMJPEG working with several text browsers. Comments indicate where it should be put into configuration files/settings to interface with these web clients. Also, it could be used as a place to add some more features, like a menu to select different image viewers/processors. Where these might be added is indicated in comments.

I'm certain people will come up with other ideas to improve this, but it works, and can get you going if have any trouble viewing images!


/*  ReXX     */

/*  
             PMGPEGgn.CMD

A wrapper function for general use with text mode browsers
To launch image viewing programs

Usage: pmjpeggn    

Make sure /* ReXX  */  comment is on the first line,
starting in the first column!
   
--
   Where to use:
Lynx:                           used in 'lynx.cfg' file
                                examples:
XLOADIMAGE_COMMAND:pmjpeggn  LYNX_TEMP_SPACE %s  &
VIEWER:image/bmp:pmjpeggn  lynx_temp_space %s &:XWINDOWS
                               (for Unix type shell)
           or
XLOADIMAGE_COMMAND:start /c pmjpeggn  LYNX_TEMP_SPACE %s  
VIEWER:image/bmp:start /c pmjpeggn  lynx_temp_space %s :XWINDOWS
                               (for CMD.EXE shell)

      Also, you should define some none-null value
           for environmental variable 'DISPLAY'
           either in CONFIG.SYS or a wrapper function being
      used to launch Lynx.
      Under some circumstances, it may
      be used as the image viewer if it is
           set to the 'volume:/path/program' being used
      as the image viewer.
                
w3m:                            used in 'mailcap' file
                                example:
image/gif  ; cmd /c pmjpeggn   PWD  %s  ; ;
   
eLinks (and probably 'links'):  used in escape/setup/associations 
                                (Then escape/setup/save settings)
                                example, inside text based interface:
c:/os2/apps/pmjpegel  PWD %
                                User will also need to define
                                extensions and types, 'www image'
                                'image/jpeg'  etc.
--
            
    might typically be:
            TMP
            TEMP
            TMPDIR
            LYNX_TEMP_SPACE
            PWD
--

                 typically is '%s' (check browser documentation)
                             when the link to the image is activated
                             from the browser, the image is downloaded
                             to a local file for viewing, but there
                             seem to be some problems this script will
                             correct.
             
*/

/*  Grab the command line parameters, by various means:  */
PARSE       ARG   .     imagefile   ;
PARSE UPPER ARG   tdir  .  ;

/*
CALL  SysCls   ;

/*
   Lip service to loading the RexxUtils  until this is really needed.
   CALL LOADLIB.CMD
   IF RC = 1 THEN  SAY "Error: Couldn't load RexxUtil library."
   /*       FROM "ReXX COOKBOOK", P. 7-2, TO REGISTER ReXXUtil DLL    */
   */
   
*/

/*  extract  the name of the temporary/scratch directory
    typicly stored in the environmental variable whose
    name is stored in 'tdir', and was passed to this program
    on invocation:    */
wdir  =  Value( tdir, , 'OS2ENVIRONMENT' )  ;
IF  '' = wdir  THEN
   wdir  =  directory()  ;
/*           ---  for shells where environmental variable
                  PWD (for instance) might not be defined.
                  PWD ~ Present Working Directory
        pass PWD as a dummy variable if
        the browser uses the directory it was
        launched in for temporary files,
        instead of a directory identified by the value
        of an environmental variable.
                  This last IF statement will then
        grab the working directory to use.
        
*/

/*   convert   directory seperators to OS/2 standard:
     Major purpose of this script - Lynx likes and gives out '/'s
     but   OS/2  utilities frequently have to have '\'s
     as directory seperators.
*/
wdir  =  Translate( wdir, '\', '/' )  ;

/*  now move to the temporary/scratch directory:   */
wdirc  =  Directory( wdir )  ;


/*  make the same correction to the image file 
    directory, if it was part of the name passed
    to this script when invoked,
    standardizing the directory seperator.
 */
imagefile  =  Translate( imagefile, '\', '/' )  ;

/*  Now extract the file name extension, so the image format
    information can be saved:
 */
ofilename = imagefile  ;
/*
SAY 'ofilename ='ofilename'='  ;
*/
DO WHILE  '' >< ofilename
  PARSE VAR  ofilename   extension  '.' ofilename
END
/*   SAY 'extension ='extension'='  ;   */

newname  =  'elqqq.'extension  ;
/*  SAY 'newname ='newname'='  ;  */

/*  Note:   Possible future improvement:
            At this point it might be desirable to ask the user
            if they'd like to permenantly save a copy of the 
            image file, and take appropriate action.
       
       For this possible improvement, the VREXX package
       might be a good choice.
*/

/* move the image to another file name because 
   eLinks browser will immediately delete the
   file before pmjpeg.exe (or possibly other image
   viewers) get a chance to render the file.
   */
'@ECHO  off'   ;
'@del  'newname'  2> NUL  1>&2  '  ;
'@Copy  'imagefile'  'newname'  2> NUL 1>&2 '  ;

/*  Note:  Possible future improvement:
           At this point it might be appropriate to ask the user,
           with a menu of choices,
           what image viewer they would like to use,
       
      For this possible improvement also, 
      the VREXX package might be a good choice.
*/

/*    This is good for all but eLinks, which has a focus problem,
      where this flips back to eLinks instead of the image viewer:
   'start "Text mode browser  Viewer"  /F  /PM  /MAX  pmjpeg 'newname   ;
   
   
   (get 'go.exe' or a similar focus/task list tool from Hobbes.)
*/

'@start "Text mode browser  Viewer"  /F  /PM  /MAX  pmjpeg 'newname   ,
  ' &&   go -j pmjpeg   2> NUL 1>&2  '   ;


EXIT  ;

Try it yourself! You can download a zip file of this script. If your image viewer is something other than PMJPEG, just modify the references in the script appropriately.


To be continued... Part 4 delves into Lynx's EXTERNAL commands with a REXX script that will do a lot of the work for you. The EXTERNAL commands will allow you to switch to another browser (like w3m or eLinks) that can better render framed pages, for example. The image viewer will not help on this. Frame does not necessarily go along with picture in this case!

    If you missed them:
  • Part 1 of this series gets you started using the Lynx browser.
  • Once you have it running, Part 2 helps you use Lynx more effectively.


The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 2002 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.