ToyViewer (Ver.3.2)


How to display other image formats

You can set ToyViewer to display any image format if there is a filter program to ppm. To do so, definition file "~/.toyviewerrc" or "~/Library/ToyViewer/rc.arch" have to be presented. Where, "arch" is a name of architectures, e.g., m68k, i386, sparc, or ppc. In the case that the executable file of a filter is for only one architecture, or in the case that the executable files for each architecture are stored in different directories, you can specify different definition files for each architecture. For example, specification of filters for Intel is written in "rc.i386".

Format of the definition file is below:

	<ext>	<path>	<args> ... 
Where, <ext> is an extension of image files, <path> is a full path name of the filter program, and <args> are arguments for the program. One of <args> should be `$', which is replaced by the image file name. If the first character of path is `~', it is extended to the home directory. If `@', it is extended to the application directory (.../ToyViewer.app/Resources). Lines beginning with `#' are comments. The following are examples.
jfif  @/djpeg $
ras   /usr/local/netpbm/bin/rasttopnm $
sgi   /usr/local/netpbm/bin/sgitopnm $
g3    /usr/local/netpbm/bin/g3topbm -reversebits $
qwe   ~/Unix/bin/qwe2ppm $ -
This customization is prior to pre-definition of ToyViewer.app. For example, if you write specification for extension `gif', gif files will be opened using specified filter.

Besides, if filter service programs such as ImageViewer.app, OmniImageFilter, or McFilter are installed, other image formats (e.g., Mac paint, sun raster, ...) can be read.

Image files treated by service programs, or specified in the definition file are opened using open panel (select "File / Open " menu) or by command-dragging the icon onto the tile of ToyViewer. Note that you can not activate ToyViewer by double-clicking the icon of the image file.

Image Conversion Filter Services

If ToyViewer is installed in the standard directory such as ~/Apps or /LocalApps, ToyViewer provides image conversion filter services. ToyViewer can provide filter services for not only applications of OPENSTEP but also applications of NEXTSTEP.
For example, you can open gif images using Preview.app, you can drag & drop a file icon of a jpg image into a RTF document of Edit.app or TextEdit.app, and so on (Image files are translated into tiff format).

If the service fails because of incomplete image file, for example, ToyViewer returns a small substitutive image to show that some error occurred.

If you specify new filter programs in the way as described above, you can also make ToyViewer provide image conversion filter services for image formats that is newly added. To do so, definition file "~/Library/Services/ToyViewer.service" have to be presented.
Now, let's suppose that we are going to add new formats that are specified in previous example to filter services. The contents of ToyViewer.service is the following.

Filter: convertToTIFF
Port: ToyViewer
Send Type: NXFilenamePboardType:jfif
Send Type: NXFilenamePboardType:ras
Send Type: NXFilenamePboardType:sgi
Send Type: NXFilenamePboardType:g3
Send Type: NXFilenamePboardType:qwe
Return Type: NXTIFFPboardType
Executable: /LocalApps/ToyViewer.app/ToyViewer
Timeout: 60000
Once this file is ready, restart ToyViewer to make enable to provide filter services.
If the services do not work successfully, type "make_services" command into a terminal, or try to login again, please.

Example

Suppose that you frequently use gray-scaled raw image data for your research. The image has 320x200 pixels and no header. Each byte in the data represents one pixel (value range: 0 - 255). Extension of files is "gs". You can display easily this format with ToyViewer.
First, make a executable shell script as below (filename=gstoppm.sh):
#!/bin/sh
echo "P5 320 200 255"
cat $1
This simple script is a converter to pbm format. Then, edit "~/Library/ToyViewer/rc.arch" and add next line:
gs      ~/Unix/sh/gstoppm.sh $
If you want to use filter service for "gs" images, make "~/Library/Services/ToyViewer.service" as the following:
Filter: convertToTIFF
Port: ToyViewer
Send Type: NXFilenamePboardType:gs
Return Type: NXTIFFPboardType
Timeout: 60000
Restart ToyViewer, and you would be able to display "gs" files with ToyViewer.

Caution

Programs cjpeg and djpeg presented by ToyViewer are modified to read and write comments in data files. Do not replace them with other programs.