Using Batch Files and Shell Scripts to Produce Apple IIgs Super-Hi Res (SHR) Screen Images

 

This article is a practical reference for the Apple II Enthusiast, and contains many hyperlinks that explain a lot, and many facts that are repeated a lot. The historical perspective and the opinions are my own. You have a royalty-free right to use, modify, reproduce and distribute the source code listings in this article in any way you find useful, provided that you agree that Bill Buckels has no warranty obligations or liability resulting from said use and distribution in any way whatsoever.   Bill Buckels, August 2016

 

Forward – Not your Father’s GIF Converter

 

The example images like the ones below and throughout this article began as “real” Apple IIgs Super Hi-Res (SHR) 320 x 200 x 12-bit screen image conversions prepared using my A2B converter and the process detailed here, and placed on an Apple IIgs disk. They were then extracted using Ciderpress which results in a double-magnified 640 x 400 equivalent that is easier to see on today’s high-resolution displays. The number of colors per image for these examples is listed in both 12-bit Apple IIgs colors, and 24-bit colors, which is the color precision that the A2B converter works with, providing greater color accuracy than the Apple IIgs display. The E-dithering in these examples is my own (Buckels dither) which was designed specifically for the Apple II display. It is accurate to a 24-bit color error. It is based on weighting similar to Atkinson but with a full color bleed. Color assignment uses Rec.709 Luma coefficients for this article (although A2B supports other standard E-dithers and color gamuts). In general, these 24-bit 16-palette and 200-palette conversions have a much greater number of post-conversion colors than the GIF file conversions that were popular “back in the day”; in the 200 palette non-dithered example below there are 333 unique 12-bit indexed colors (2336 24-bit indexed colors) … but a GIF file can only hold 256 24-bit colors before conversion, much less than the 16.7 million colors available to the A2B converter’s 24-bit input files.

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 108 Unique Apple IIgs Colors (244 Unique 24-bit colors)

200-Palettes Non-dithered – 333 Unique Apple IIgs Colors (2336 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 108 Unique Apple IIgs Colors (243 Unique 24-bit colors)

200-Palettes E-dithered –  264 Unique Apple IIgs Colors (1201 Unique 24-bit colors)

 

Table of Contents

 

Using Batch Files and Shell Scripts to Produce Apple IIgs Super-Hi Res (SHR) Screen Images. 1

Forward – Not your Father’s GIF Converter. 1

Table of Contents. 1

Introduction – Fun Facts. 2

Slicing Super Hi-Res External Segmented Palettes (ESP) with ImageMagick. 2

Color Space and Color Matching vs. Heroics. 3

Time and Tide Wait for No-one. 3

Glass Houses on the Trailing Edge of Ugly. 4

The Stock Apple II Display Today. 5

The Argument for the Simplicity of Old (and New) GIF Converters. 6

Overview – Various Types of Apple II Graphics Files. 6

What is a “Foreign” Graphics File?. 6

What is a “Native” Apple II Graphics File?. 6

Automating the Conversion Process. 6

Workflow.. 6

Before you begin – Set-up Notes. 7

Original Source and Win32 Download. 7

OSX 10.9 and Debian 8 Binaries Download. 7

Manual Methods up to Step Three. 7

Running Batch Files or Shell Scripts in Windows. 7

Running Shell Scripts in Linux or OSX.. 7

ProDOS File Names. 7

Input Image Type and Input Image Resolution. 7

Proportionate Presentation and Framing the Picture Area. 8

Step One – Cropping and Padding the Input Image. 8

Manual Cropping. 8

Automated Cropping. 9

Mass Cropping of Identical Size Images. 9

Batch File Example. 9

Shell Script Example. 9

Mass Cropping of Arbitrary Sized Images. 9

Batch File Examples – aspect43.bat and cropper.bat 9

Work Files. 10

Shell Script Example – aspect43.sh. 10

Work Files. 11

Editing Input Images. 11

Adjust the Color Balance before Cropping. 12

Padding the Input Image to 4:3 Aspect Instead of Cropping. 12

Automated Mass Padding instead of Cropping. 13

Batch File Listing – pad43.bat 13

Work Files. 14

Shell Script Listing – pad43.sh. 14

Work Files. 14

A2B Source Code Listing – Cropping and Padding Script Output for ImageMagick Automation. 15

Step Two – Scaling the Cropped Input Image. 16

Scaling in a Windows Batch File using ImageMagick. 16

Adding Captions to A Scaled Input Image. 16

Step Three – Slicing the Input Image into 16-color Palette Files. 17

Step Four – Converting to SHR.. 17

Step Five – Creating an SHR Slideshow.. 18

The Local Slideshow and Review of Converted Output 18

Batch File Listing – magall.bat 18

Shell Script Listing – magall.sh. 19

Removing Unwanted Conversions. 20

Batch File Listings for Removing Unwanted Conversions. 20

Shell Script Listings for Removing Unwanted Conversions. 21

Process Batch Files and Shell Scripts and the Working Directory Structure. 21

Step Two – Batch File Source Listing - cvt2bmp.bat 21

Step Two – Shell Script Source Listing - cvt2bmp.sh. 22

Step Four – Batch File Source Listing - Cvt.bat 23

Step Four – Shell Script Source Listing – cvt.sh. 23

Step Three – Batch File Listing – slicer.bat 24

Step Three – Shell Script Listing – slicer.sh. 26

 

Introduction – Fun Facts

 

This is a technical article is about converting modern graphics images to Apple IIgs Super Hi-Res (SHR) 320 x 200 screen images using my A2B converter in conjunction with ImageMagick (required) and other modern graphics utilities. The process detailed here is cross-platform and works on most modern computers; Various Versions of Windows computers (tested in Windows XP, 7, and 10), and Unix-like computers including Mac OSX and Linux computers.

 

Windows continues as the most-used operating system family for personal computers as of June 2016 with close to 90% usage share, so for most of us batch files work remarkably well. But for those in the Apple II Retrocomputing Community that use non-windows systems, shell scripts are also offered in this article.

 

At the time of this writing, (summer of 2016), ImageMagick has moved forward to version 7.  This article is a targeted at the new version 7, but was originally tested against version 6.9. The batch files and shell scripts needed to be changed slightly to accommodate ImageMagick’s move to version 7’s consolidated CLI. If you are using Windows 10 like 350 million of us (22% of the personal computers on The Planet and far greater than all devices on the planet running Mac OS and iOS combined); for a new ImageMagick installation, the simplest thing you can do is to use the latest version of A2B with ImageMagick version 7. Configuring your system for use is covered in more detail further in this article in the section “Before you begin – Set-up Notes”.

 

Slicing Super Hi-Res External Segmented Palettes (ESP) with ImageMagick

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 113 Unique Apple IIgs Colors (197 Unique 24-bit colors)

200-Palettes Non-dithered – 279 Unique Apple IIgs Colors (1446 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 113 Unique Apple IIgs Colors (197 Unique 24-bit colors)

200-Palettes E-dithered – 249 Unique Apple IIgs Colors (961 Unique 24-bit colors)

 

Apple IIgs 320 x 200 Super Hi-Res (SHR) modes use indexed palettes with a maximum of 16 colors per line from a maximum of 4096 colors. 3 popular SHR modes are 1-palette (mode320 single palette), 16-palettes (mode320 multi-palette), and 200-palettes (mode3200 aka Brooks mode). The approach I use to convert these, and covered in this article, is to uniformly divide an image into horizontal slices that correspond to palettes; a single palette will have only one slice the size of the whole image, a 16-palette image will have 16 slices within the image, and a 200-palette image will have 200-slices of one image line per slice.

 

Modern graphics editors like ImageMagick do an excellent job of quantizing modern graphics to 16 colors, so I decided to lever this ability by providing an option called External Segmented Palettes (ESP) that externalizes the quantization used by the A2B converter; External Segmented Palettes (ESP) are horizontal slices of an image created by ImageMagick that have been quantized into 16 colors.

 

ImageMagick’s CLI makes it ideal for this automated process, as well as for automating image preprocessing and output post-processing.

 

Color Space and Color Matching vs. Heroics

 

The A2B converter like many modern graphics utilities uses a Euclidian Distance Algorithm to match colors in a 24-bit image with the nearest palette color. Due to SHR’s restriction of only 16 colors per line and the fact that there can be 320 unique colors per line in a 24-bit image before conversion, the A2B converter must agree mathematically with the measurements used by the “Original” input image and not use some “home-made” mapping technique to assign colors to a palette. A2B’s external palettes used by its ESP option must also agree mathematically with the measurements used by the “Original” input image and with all transformations of that input image, including cropping and padding, and scaling and saving. In all of this, the standardization of Color Space is important.

 

Like many if not most modern graphics editors, the A2B converter understands and implements standard color spaces, using standard coeffients to match colors to target displays.

 

For example if we were targeting an  NTSC television for DHGR output using a properly phased signal from an Apple IIe, we would use a hard-coded 15-color 24-bit conversion palette based on Sheldon Simm’s work with the AppleWin NTSC emulator and the tohgr converter. We would use Rec. 601 Luma coefficients to re-map the modern color gamut even though the “Original” input image likely uses sRGB color space.

 

But if we were targeting an Apple IIgs RGB display with a crt monitor for DHGR output, we would use a hard-coded 16-color 24-bit conversion palette based on Super Convert and also used by the Kegs32 emulator. We would use Rec. 709 Luma coefficients to map the modern color gamut “as-is”. But our results still wouldn’t be as good as on an Apple IIe with a television as a monitor, because the Apple IIgs RGB display’s DHGR colors are not phased perfectly like the Apple IIe’s NTSC DHGR colors, and the RGB display does not provide NTSC artifacting which creates the advantage of subpixel rendering. As far as plugging a television into the the Apple IIgs composite output; it still uses the RGB display’s DHGR colors so even though artifacting occurs it has lost the advantage of the properly phased colors of the Apple IIe composite output.

 

However, if we target an an Apple IIgs RGB display with a crt monitor for SHR output, and use Rec. 709 Luma coefficients to map the modern color gamut “as-is”, our colors will generally be equivalent, and the SHR output will usually agree with the color space in the “Original” input file; a jpeg image generally uses sRGB as previously noted, the color gamut is well understood and the coefficients are standardized. even if they weren’t standardized, A2B offers the option of using a simple text file for coefficients from some other gamut.

 

While this is admittedly not as straight-forward as just running some old GIF converter and hoping for the best, the standards exist for a reason, and the reason is color science, and the goal is to obtain the most accurate results possible and not simply “heroics”.

 

Time and Tide Wait for No-one

 

It was for very good reason that “foreign graphics” found their way to the Apple IIgs. On the PC during the time that the Apple IIgs was in wide use, we were already working with 24-bit True Color Images in our vertical market applications. The Apple IIgs SHR display was trailing-edge almost from the year that it was introduced, so it could not have worked very well the other way around.

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 118 Unique Apple IIgs Colors (238 Unique 24-bit colors)

200-Palettes Non-dithered – 290 Unique Apple IIgs Colors (2317 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 119 Unique Apple IIgs Colors (238 Unique 24-bit colors)

200-Palettes E-dithered – 251 Unique Apple IIgs Colors (1249 Unique 24-bit colors)

 

The Apple IIgs was released September 15, 1986 with a graphics display capable of a maximum of only 16 colors per line, and with no further improvement to its display hardware from Apple Computer after its introduction, Apple IIgs graphics were soon left far behind. About 6 months later, on April 2, 1987, IBM released the MCGA display with 320 x 200 x 256 colors anywhere on the screen. Both VGA and SuperVGA followed that same year.

 

Also in 1987, Truevision, the pioneer of the desktop digital video editing industry, introduced the Targa Board for IBM PC compatible computers. The Targa Board provided video capture in 512 x 480 TGA truecolor file format and could display over 32,000 colors anywhere on the screen. A lower cost video capture board for the PC, the Everex ev680, with the same capabilities as the Targa Board soon followed. From about 1990, truecolor VGA cards for the PC, like the Everex ev629 and the ATI Wonder XL, became available, and quickly became affordable. By 1990, with 16 million units sold that year and 84% of the personal computer market, the IBM-PC and clones with inexpensive VGA cards and monitors had become the personal computer video standard, including for new games.

 

By the end of production in 1993, somewhere between five and six million Apple II series computers (including about 1.25 million Apple IIGS models) had been produced. It was not until 1994, two years after Apple Computer had discontinued the IIgs (with less than 2 million units sold over its lifetime), that work on a 3rd party VGA card for the Apple IIgs would begin, with only 400 or so “Second Sight” cards being sold by 1999. 

 

In 1987, the Macintosh II offered an RGB color display, with Apple Computer continuing to put most of their internal resources into the Macintosh. Even after the Macintosh's introduction, the Apple II had remained the company's primary revenue source for years. The computer was the first to attract a loyal user community and many outspoken Apple II fans were bitter that the company had invested its Apple II profits into the Macintosh rather than using them to further the Apple II series.

 

The Macintosh II could display true color photorealistic images, but had a very high price tag that was unaffordable to most personal computer users. In 1992, 80 years after the sinking of The Titanic, Apple Computer discontinued the Apple IIgs, and Microsoft released Multimedia Windows 3.1. Macintosh market share reached a peak at 12% in 1993 but declined to less than 4% by 1999. By 2004, the IBM-PC and clones had 97% of the personal computer market share and Macintosh had less than 2%. Over 173 million personal computers were sold in 2004.   

 

Glass Houses on the Trailing Edge of Ugly

 

In 1987, Compuserve released the GIF file format which was well matched to the IBM PC compatible 256 color displays; both support 256 colors anywhere. The GIF file stores an arbitrary palette selecting from 16.7 million 24 bit colors. The PC’s 256 color display selects from an arbitrary palette of 262,144 18 bit colors. GIF files saw wide use on the PC from the very start. A GIF file is not a true color photorealistic image; those would follow later when the PC world was ready for them.

 

The Apple IIgs with a limit of 16 colors per line, and a 12 bit arbitrary palette selecting from only 4096 colors, was not ready for the GIF file. GIF file converters for the Apple IIgs like Convert3200, Prism and SuperConvert appeared in the early to mid 1990s. Even though the GIF file may have been beautiful when displayed on the PC, the Apple IIgs conversion could be downright ugly.

 

By the early 1990’s Apple IIgs Super Hi-Res Graphics were very trailing edge (and the earlier Apple II graphics stuff was long obsolete). The Apple II graphics conversion utilities that were around back then are not effective by comparison to what we can do today using modern tools and techniques like the process detailed here. (From my view, the Apple II graphics conversion utilities that were around back then are not even effective by comparison to what was available back then on computers like the IBM PC compatible or the Amiga.)

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 126 Unique Apple IIgs Colors (217 Unique 24-bit colors)

200-Palettes Non-dithered – 364 Unique Apple IIgs Colors (2307 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 126 Unique Apple IIgs Colors (217 Unique 24-bit colors)

200-Palettes E-dithered – 284 Unique Apple IIgs Colors (1203 Unique 24-bit colors)

 

The restriction of only 16 colors per line also does not lend itself to displaying continuous tone images on the 320 x 200 SHR display without horizontal aliasing, so color accuracy needs to be “spot-on” to achieve a modicum of success in minimal aliasing. And this is where Oversampling and high resolution “Original” input files come-in to an otherwise pretty dismal mix.

 

  1. As a rule of thumb, and if at all possible, when you are converting a continuous tone image for the Apple IIgs 320 x 200 SHR display, the greater the resolution of the “Original” input image the better. You will never be wasting computing power by oversampling an input image (despite what you may read elsewhere “in the wild”).

 

  1. As a rule of thumb, converting a “lossy” “Original image” to a 24-bit cropped or padded BMP equivalent will only ensure that you have provided the most accurate color information for modern converters like the A2B converter to use, for palette creation and mapping during quantization and palette optimization.

 

  1. Always scale the highest resoloution “raw” “Original” input file using a high quality scaling algorithm, which includes ImageMagick’s default or The GIMP’s Lanczos algorithm. Scaling algorithms are not all created equal even in modern editors. Color Space too is important. The Default Color Space of a jpeg is generally sRGB. If you are using ICC Color Management, or some other Color Space, you are not necessarily going to achieve the equivalent results, so it is always best to carefully select and stay with known high-quality graphics editors to minimize inconsistent results.

 

The Stock Apple II Display Today

 

Home computers were a class of microcomputers entering the market in 1977, and becoming common during the 1980s. In 1977, the Apple II series of home computers began production, with the last in the series, the Apple IIGS, introduced in 1986. After 1987, IBM PC compatibles dominated both the home and business markets of commodity computers. In 1987, with the introduction of the VGA as the lowest common denominator that virtually all graphics hardware could be expected to implement, Apple II graphics were soon left far behind.

 

Graphics programming techniques and graphics editing software have evolved considerably in recent years. Many traditional disciplines are now integrating digital technologies and, as a result, the lines between traditional works of art and new media works created using computers has been blurred; available content undreamed of during the 70’s and 80’s abounds.

 

Despite all that, today there continues to be little interest from the Apple IIgs Retrocomputing community, in displaying conversions of modern Continuous Tone Images on a “stock” Apple IIgs display. But a small number of retro-programmers including Sheldon Simms, Jonas Grönhagen and me, have recently written various conversion utilities that use modern techniques to produce output rendered for exactly that purpose, with varying degrees of success. One common thread of our converters is that we judge our output by modern notions of beauty; retrocomputing includes active software development and the use of vintage computers for purposes that they were otherwise never intended. Cross-platform programming is the practice of actively writing software that will work on more than one platform. This is another common thread that our converters share.

 

This is not considered to be retrocomputing by some, as it is made possible by modern computer software and hardware. In general, most of the interest in Apple IIgs graphics today is in the pixel art including graphics for Apple IIgs video games and demos, and also file conversions of “foreign graphics” in GIF format, that are all judged by standards of beauty that persisted on the Apple IIgs long after the rest of the world had changed over time to modern notions of beautiful computer graphics.    

 

The SHR display is a picture plane and only suitable for a display palette. The effective 12-bit color gamut of the SHR display does not contain enough colors to accurately map a 24-bit continuous tone input image. E-dithering of a 24-bit input image in particular does not work effectively using SHR’s 12-bit display gamut to calculate color error. Integer math also does not work accurately enough to calculate color error for E-dithering, nor for color matching, so double precision floating point math is used by the A2B converter. 24-bit quantization is also used to create suitable conversion palettes, especially when a 24-bit continuous tone input image has fewer colors, to avoid extreme banding and posterization. Matching palettes for least error during E-dithering must also use floating point math for comparing cumulative line error. Dithering must use integer math, both signed and unsigned, and not bytewise math to avoid overflow and underflow. Clipping of error is minimized during color-mixing associated with E-dithering.

 

It is not until after conversion at the time that the SHR screen image output is written to disk, that the 12-bit color gamut is ever used during an accurate conversion of a 24-bit continuous tone image, whether the output is E-dithered or Raw (non-dithered). Original input images are best scaled raw in 24-bit color from the highest resolution available. Typically Rec. 709 color space is the most effective for color mapping in the converter, and is compatible with sRGB like in most jpeg’s used for the initial pre-conversion to a raw BMP (before scaling, to avoid input image color loss). For E-dithered output, the color error remainder is randomized into the weights of the pattern.

 

A learning curve is required whether you use old programs or today’s color science to convert modern graphics to vintage graphics, so it only makes good sense to use modern conversion methodology. But if you are waiting for someone (maybe me) to write a converter with a graphical user interface (rather than a CLI) that produces the equivalent of the output detailed here, or to update the old programs with new programming that is equivalent to what A2B and ImageMagick have to offer, you could wait a long time, perhaps forever. So even if you are out of your comfort zone using a CLI and batch files or shell scripts to convert modern graphics to Apple II graphics, I would encourage you to make the effort required to get comfortable with the process detailed here, in the interests of getting-on with things. 

 

The Argument for the Simplicity of Old (and New) GIF Converters

 

With all this talk of Color Science and the inherent complications of converting Modern Continuous Tone Input Images to simple Apple IIgs 320 x 200 SHR graphic screens, it is easy to lose sight of my particular goal of displaying modern graphics to their best advantage on an old computer like the Apple IIgs. To begin with, there has never generally been a “real requirement” to see these types of graphics on the Apple IIgs. The Apple IIgs display itself was designed to offer a compromise between old Apple II graphics modes, graphics for the GS/OS desktop, and games that more or less “followed the rules” to their current state of near demise. Through it all, today’s Apple IIgs Retro-computing Community that still barely exists has little interest for an endeavor like this one that is virtually and historically unprecedented.

 

It is undeniable that the hand-made Pixel Art that pervades the Apple IIgs “game scene” is well-done as Pixel Art goes, and generally more pleasing to look at than poorly controlled conversions of modern images, and badly converted old GIF file conversions done by old converters. But simply put, GIF files and the converters that use them do not work properly when compared to modern converters that convert modern images.

 

Ignoring the lack of any practical need for this for the time being, let’s look at the GIF file a little deeper, and try to understand why exactly it does not suit my admittedly impractical goal.

 

A GIF file is generally formatted for the IBM-PC and compatible MCGA mode. This causes a whole lot of problems when colors have already been compromised before a conversion targeted at the Apple IIgs take place, because the accuracy of the “color error” in the GIF has disappeared beyond recovery, lost by the quantization that was imposed on it by its IBM-PC creator.

 

If it weren’t for the fact that only up to 16-colors per line can be displayed in SHR at the best of times, throwing away least used colors and similar desperate techniques used by GIF file converters would be even less likely to succeed when compared to modern and precise quantization techniques used by modern converters of 24-bit images.

 

Subtle changes in tones throughout a continuous tone image provide a smooth appearance on a modern 24-bit display, but many variations in tone are lost when a 24-bit color is reduced to the effective color gamut of the Apple IIgs display, which only selects from a palette of 4096 colors.

 

Overview – Various Types of Apple II Graphics Files

 

In 1977, the Apple II series of computers began production, launching the Home Computer era. The first Apple II model had very limited graphics capabilities, and supported only 2 graphics modes:

 

  • Lo-res (40×48, 16-fixed colors)
  • Hi-res (280×192, 6-fixed colors) – technically, the resolution of Hi-res mode is 140 x 192 color, and 280 x 192 black and white, and technically every 3.5  color pixels can only display 2 consecutive colors in either a Violet and Green palette, or Blue and Orange palette. 

 

The last II-series Apple in production, the Apple IIe, introduced in 1983, was discontinued on October 15, 1993. The Apple IIe added 2 additional graphics modes:

 

  • Double Lo-res (80×48, 16-fixed colors)
  • Double Hi-res (140×192, 16-fixed colors) – technically, the resolution of Double Hi-res mode is 140 x 192 color, and 512 x 192 black and white.

 

The Apple IIGS sold from 1986 until the end of 1992. The Apple IIgs added 2 additional graphics modes:

 

  • 320 x 200 x 16 palettes of 16-arbitrary 12-bit colors
  • 320 x 200 x 16 interleaved palettes of 4-sub palettes of 4-arbitrary 12-bit colors

 

The 320 x 200 resolution graphics mode can be animated to provide 200 palettes (a separate palette for every line). This is cpu intensive and requires expert programming. 

 

What is a “Foreign” Graphics File?

 

Wikipedia limits its definition of “Native” and “Foreign” computer file formats to describing how software applications perceive a file, but that’s only one way of looking at it.

 

My Wikipedia article on the “Legacy” BSAVE bitmap format is also only one way of looking at “Native” and “Foreign” computer file formats; in a hardware-dependent or device-dependent context. A “Foreign” Graphics File is a Graphics File that comes from a different computer. For example, a BSAVE image of video memory from an IBM-PC 320 x 200 x 4 color CGA display is a “Foreign” Graphics File when it is on an Apple IIgs computer. But when the same BSAVE image is converted to a “Native” 320 x 200 color Apple IIgs Super Hi-Res (SHR) Screen Image Graphics File, it is no longer a “Foreign” Graphics File when it is on an Apple IIgs computer; it is a “Native” Apple IIgs Graphics File.

 

The whole notion of whether a “Legacy” file was “historically” described as “Native” or “Foreign” can also be “cultural”, depending on what kind of “Classic” computer the file was created on (the source computer) and what kind of “Classic” computer the file was edited or displayed on (the target computer). From the 1980’s when I worked as a graphics software developer on the IBM-PC, I don’t ever recall referring to any graphics file as “Foreign”, and it never dawned on me to do so until recent years, when my “research” (aka retro-computing hobby) led me to become one of the very few software developers on the planet to provide modern conversion software that uses “Foreign” Graphics Files to create the bulk of newly-created “Native” Apple II Graphics Files that can be found on the planet in 2016. Apple Computers almost vanished from the planet throughout the 1990’s, despite the fact that users of Apple computers still referred to Device Independent Graphics files as “Foreign”. It’s probably fair to say that describing those as “Foreign” files is “AppleSpeak” terminology; from before us “foreigners” took over, meaning a graphics image that was not created in a “Legacy” file format that is “native” to an Apple Computer.

 

Today many modern graphics file formats are also used interchangeably on most modern computers. This was a concept that was foreign to Apple Computer but not to the IBM-PC; in those days, Apple Computer was preoccupied with Metadata and officially “blessing” files that followed their rules, while we IBM-PC graphics software developers continued to do our own thing the same way we always have. The Apple II DOS filing system used File Types, and Apple II ProDOS expanded the use of File Types. By comparison MS-DOS and Unix file types were quite simple during the same period of history and even until today. The Apple IIgs filing system extended the ProDOS filing system with resource forks further complicating things. That’s all ancient history and today many filing systems have been used on desktop computers.

 

Today from my view of the Apple II, a “Foreign” Graphics File is any graphics file that is not in a “Native” Apple II Graphics File format.

 

What is a “Native” Apple II Graphics File?

 

“Native” Apple II Graphics Files can be “loosely” divided into 3 common “vintages”, based on the graphics capabilities of the Apple II model:

 

  1. The first Apple II (and Apple II plus) computers expanded the 40 x 48 x 16 color Lo-res graphics by adding 280 x 192 x 6 color Hi-res graphics.
  2. The later models (IIe, IIc, IIc Plus) expanded the 2 maximum resolutions by adding 80 x 48 x 16 color Double Lo-res graphics and 140 x 192 x 16 color Double Hi-res graphics.
  3. The Apple IIgs added 320 x 200 x 4096 color and 640 x 200 x 4096 color Super Hi-res graphics.

 

There is a lot more to understanding “Native” Apple II graphics files than the simple summary above. However, one thing all “Native” Apple II graphics files have in common is that they are device-dependent on the Apple II in some way or another.

         

Automating the Conversion Process

 

Producing device dependent Apple IIgs Super Hi-Res (SHR) 320 x 200 Screen Image output from modern Continuous tone bitmapped graphics images with batch files or shell scripts is effective for both:

 

  • Individual Image Conversions
  • Mass Image Conversions

 

Workflow

 

Tasks

Methods and Materials including

Batch File or Shell Script Base Name

Synopsis

Before you begin

Set-Up

 

  1. Create and Set-up the Working Directory.
  2. Download and install the binaries.
  3. Install the batch files or shell scripts in the
  4. Working Directory and edit paths to binaries.
  5. Set-up permissions as needed.

ImageMagick convert utility

A2B converter version 8 or greater

Batch Files for Windows systems

Shell Scripts for Unix-like systems

commandline graphics editor

commandline SHR converter

provided with A2B

provided with A2B

When you begin

“Original” Input Image Files

 

  1. Acquire the original Input Image Files.

BMP, jpeg, png, GIF, etc.

(GIF files are not continuous tone images,

Pngs often are not, jpegs often are, others vary.)

 

  1. Place in the Working Directory.
  1. Create in a graphics editor
  2. Download from the Internet
  3. Digital Camera output files
  4. Desktop Scanner output files
  5. Etc.

The GIMP, etc.

Google Images, etc.

Home photos

Step One

Cropping and Padding

 

  1. Crop or Pad to 4:3 Aspect Ratio as Required
  2. Save (export) to 24-bit BMP

 

Interactive Graphics Editor

Aspect43

Pad43

Edit and/or Crop or Pad to 4:3 Aspect Ratio

Centre Crop to 4:3 Aspect Ratio

Center Pad to 4:3 Aspect Ratio

Step Two

Scaling

 

  1. Input 4:3 Aspect Ratio square pixel Image.

BMP, jpeg, png, GIF.

  1. Scale to 320 x 200 Resolution 24-bit BMP.

Interactive Graphics Editor

Cvt2bmp

 

Step Three

Convert to native SHR Images

 

Convert

  1. Output SHR files
  2. Output Preview Files

cvt

Output 1-palette, 16-palette, and 200-palette 320 x 200 SHR Screen Images,

Both Non-dithered (raw) and E-dithered.

Also output editable BMP preview files that can be re-processed after editing.

Step Four

View and Edit on a Modern Computer

 

  1. Preview Magnified Output

Magall

In Windows these magnified preview images can be run as a slideshow.

  1. Delete Unwanted Files

Kill and Killpalette

 

Step Five

View on the Apple IIgs

 

  1. Place on Apple IIgs Disk or Disk Image.
  2. Create Slideshow

Manual

Manual (optional)

Ciderpress can be used in Windows.

 

Before you begin – Set-up Notes

 

This workflow should work on most modern computers, including Windows, Linux, and Mac OSX systems.    

 

As with any workflow, your system must be configured to support this workflow (as previously summarized). While this workflow was developed in Windows XP using batch files, etc., the equivalent workflow was developed in the msys unix-like shell for Windows using shell scripts, etc; whether you use the Batch Files or Shell Scripts provided, and described here, this workflow is functionally identical, except for whatver nuances exist between the various operating systems that can be used. Both ImageMagick and the A2B converter are non-interactive command line utilities with no dependencies on user interfaces that are unique to any particular modern computer.

 

  • A2B Version 8 (or later) for your system must be installed.
  • The conversion batch files or scripts for your system must be installed.
  • ImageMagick Version 6.9 (or later) for your system must be installed.

 

The A2B converter was developed in Windows XP and is distributed with a compiled Win32 binary and Ansi C Source Code. Users of Unix-like non-Windows Operating systems including Linux and Mac OSX may need to compile their own A2B binaries. The A2B converter and the batch files and shell scripts in this article are distributed as part of a larger package that also contains the latest versions of my Bmp2DHR (B2D) and M2S converters. Download Win32 binaries and latest versions complete with source at the following link:

 

Original Source and Win32 Download

 

http://www.appleoldies.ca/cc65/programs/dhgr/bmp2dhr.zip

 

You have a royalty-free right to use, modify, reproduce and distribute the above zip file including source code in any way you find useful, provided that you agree that Bill Buckels has no warranty obligations or liability resulting from said distribution in any way whatsoever.

 

OSX 10.9 and Debian 8 Binaries Download

 

http://www.appleoldies.ca/cc65/programs/dhgr/bmp2dhr-lmb.tgz

 

The above is courtesy of Les Barrows. You have a royalty-free right to use, modify, reproduce and distribute the archive below including source code in any way you find useful, provided that you agree that neither Les Barrows nor Bill Buckels have any warranty obligations or liability resulting from said distribution in any way whatsoever. Les Barrows notes are as follows:

 

“I've built binaries under OS X 10.9 and Debian 8 x86_64, they're under the bin directory structure. Note that I had to rename the output of the xpack executable to xpack2 while building, since otherwise it conflicts with the xpack directory at the top level where the Makefile wants to put it. I suppose I could have added a .bin suffix or the like, but it's working. I may have done something to the sample images while testing the scripts, but the source and makefiles are all working.” - Les Barrows, August 2016

 

Manual Methods up to Step Three

 

In general, manual methods (interactive graphics editors and paint programs) can be used effectively up to Step Three of this workflow, but are somewhat labour intensive, and tedious for the beginner or casual user. Since Step Three requires the installation of ImageMagick, unless you have some compelling reason to do “fancy” hand-edits there is really no point in doing much manually. Since the primary purpose here is to provide Batch File and Shell Script listings, more details about manual methods and “fancy” hand-edits can be found in the other articles related to the A2B Converter.

 

Running Batch Files or Shell Scripts in Windows

 

Running batch files in Windows is even easier today than it was when the MS-DOS command interpreter was in wide use in the 80’s. You can still run them the old fashioned way, by typing the batch file base name from the Windows cmd prompt, or by double-clicking or opening them in Windows Explorer. Writing them in a text editor is not so terribly difficult either. Some Windows users use Unix-like shells like Cygwin or Msys to allow them to run Shell Scripts on Windows machines, but there is really no need to do so, except for personal preference. Unix-like shell users in Windows likely need no help running or writng Shell Scripts. There’s lots of good information about both Batch files and Shell Scripts on the Internet.

 

Running Shell Scripts in Linux or OSX

 

Chances are pretty good that Linux users will already know about running Shell Scripts in a Unix-like console (and about writng them in a text editor as well). Mac OSX users may not know much about Shell Scripts. In general there are two ways to run a Shell Script in OSX; in terminal by typing the script name at the command line, and in Finder by double-clicking with the mouse. There’s lots of good information about Shell Scripts on the Internet.

 

ProDOS File Names

 

Keep in mind that ProDOS File Names used on the Apple IIgs can only be 15 characters long and must begin with a letter. The A2B converter’s automatic naming uses a 4-character extension beginning with a period, which leaves you with a maximum of 11-characters for the basename of your input file. The A2B converter does not prevent you from using whatever length you wish for the basename of an input file, so you are on your own when it comes to basename length. The Batch files and Shell Scripts listed here produce SHR output with CiderPress file attribute preservation tags, which tell CiderPress which ProDOS File Type and Auxiliary Type to assign the file to when placing on an Apple IIgs disk or disk image (using A2B option “T” – tag) which you can remove in the cvt Batch file or Script if you want unadorned output.  CiderPress will also truncate file names that are too long when placing on a disk or disk image. The A2B converter uses a .SHR extension for 1-palette output, a .SH2 extension for 16-palette output and a .SH3 extension for 200-palette output. These will end-up truncated by CiderPress when placing on a disk or disk image if the name is too long for ProDOS.

 

Input Image Type and Input Image Resolution

 

So what do we mean by “Input Image Type”? What we definitely do not mean is ProDOS File Type! ProDOS File Types are only used for native mode output files after we convert them. When we talk about input image types we are describing how the “Original” Input Image was created; i.e Was it created by hand in a vintage paint program? Or was it created by hand in a modern paint program? Etc.

 

Much has been written about image processing (over the years and recently), and what kind of input provides the best output results. This is a very complicated topic. If you were expecting a simple topic, or expecting things to have become less complicated as the Apple IIgs display got older, I am sorry to inform you that as image processing technology has advanced so has the complexity of that technology. So in order to get the best possible SHR output from any “Original” input image, a strong understanding of the related technical details combined with a well organized and consistent workflow is more necessary than it ever was.

 

While image resolution is only one of the many details to pay attention to when selecting and preparing input files for conversion, the importance of image resolution cannot be overstated. At the same time, when conversions were coarser, and commonly available input image resolution wasn’t as high, neither were our standards and our expectations. You can safely ignore the recommendation of using the highest “Orginal” input image resolution available if you don’t care about improving the quality of your SHR output over what was historically available; that is your choice. But if you are concerned with producing the highest quality SHR conversions currently possible then you must preserve all available color information starting with the highest available “Original” input image resolution.

 

The rules for converting Pixel Art and Line Art can be completely different than for converting digital photos and other continuous tone content. The very easiest conversion is to create 320 x 200 x 16 color non-dithered SHR output from a 320 x 200 x 16 color “Original” input image of pixel art. But as the number of colors increases in a 320 x 200 input image, results can degrade rather spectacularly, because SHR images can only display 16 colors per line. However, even if only the same 16 colors are used throughout a pixel art (or a line art) “Original” input image, if the resolution is 320 x 240 as it will be in a typical square pixel “Original” input image (with a pixel aspect ratio (PAR) of 1:1), that will scale proportionately to the equivalent 320 x 200 SHR display resolution (with a PAR of 8:5), many more in-between colors will be created by scaling the vertical axis only.  If a 16-color “Original” of pixel art needs to be scaled from a screen resolution like 1024 x 768 proportionately to SHR’s 320 x 200 resolution, despite the fact that the display aspect ratio (DAR)  is 4:3 for both screens, but.the Storage Aspect Ratio (SAR) does not agree at all, even more in-between colors will typically be created, because both the vertical and horizontal axes will be scaled unevenly. One solution to converting pixel art is to preserve pixel color at the expense of proportion by converting by even factors, and not altering the SAR.

 

Old Apple IIgs image converters (like Convert 3200, Super Convert 4, and Prism) that typically converted 320 x 200 x 256 color GIF files to SHR files with only 16 colors per line avoided the problem of scaling from square pixels to rectangular pixels altogether. They still needed to deal with the inherent inaccuracy of a GIF file’s limit of only 256 colors per image which was generally optimized for the IBM-PC’s 320 x 200 display which supported a 256 color palette selected from an effective color gamut of 262,144 18-bit VGA colors that could appear anywhere on the display.  These old converters all worked differently from each other, and in general none does a very good job when compared to equivalent conversions using a modern converter like A2B. This is for a variety of additional reasons including the fact that A2B uses 24-bit color and other modern techniques, including Error Diffusion Dithering (E-dithering) in color. In fact it seems that these old converters didn’t “have a clue” how to do E-dithering in color, nor standard nearest color using Luma coefficients, color gamuts and color space. It also seems likely that these old converters worked in only 12-bits of color, which is definitely not accurate for converting a 24-bit comtinuous tone image properly, but no worries because a GIF file is not suitable for storing a continuous tone image, despite the fact that a modern converter like A2B still generally does a better job converting a GIF file to SHR than an old converter.

 

Some of the advice in the wild about image resolution provides guidelines for today’s would-be digital artists and photographers, so this is also where we must begin our understanding. At the time of the Apple IIgs, Apple Computer provided no advanced help for screen graphics at the level required to display a continuous tone image to its best advantage on the 320 x 200 SHR display. Even Apple’s own “lossy” Atkinson E-dithering was not suitable for rendering SHR graphics in color because it was targeted at black and white graphics and used a reduced color bleed which is more suited to print media than to color screen graphics. The weights in Atkinson are flawed for screen graphics (color accuracy is lost), but the diffusion pattern is a good one, better than Floyd-Steinberg because it diffuses the “color error” further and more evenly, so the A2B converter uses the Atkinson pattern with a full color bleed and randomization of rounding errors to achieve its default “Buckels” E-dithering of Apple II screen graphics.

 

Proportionate Presentation and Framing the Picture Area

 

Classic Desktop Computer Displays (CRTs including TVs) generally have a Display Aspect Ratio (DAR) of 4:3, regardless of the resolution of the display mode. Modern Desktop Computer Displays (LCDs) are typically proportionally wider than Classic Computer Displays; like today’s LED TV’s, Modern Displays generally have a DAR of 16:9. So it is impossible to display a full screen image from a modern display proportionately on a full screen classic display without either:

 

  1. Cropping chunks off the left or right edges, (or cropping an image fragment) or
  2. Padding (letterboxing) the top and bottom of the classic display, (or pillarboxing or windowboxing the image in the display).

 

  • The problem with padding the image is that the actual picture area is smaller than the height of the classic display, so details and image quality will generally be lower than if the entire screen of the classic display is filled with the picture. On the plus side, padding an image can be easily automated in a Windows batch file or Unix Shell Script using ImageMagick and my A2B converter.

 

  • The problem with cropping the image for the classic display is that a portion of the image will be missing. This also creates the problem that unless the subject of the modern picture area is centred, cropping including deciding how to best display the picture output for the classic display cannot be automated, and therefore is exclusively a manual process. On the plus side, cropping a centred image can be easily automated in a Windows batch file or Unix Shell Script using ImageMagick and my A2B converter.  

 

There are many sources for modern input images for conversion. High quality desktop wallpaper is abundant and readily available through sources like Google Images and generally provides excellent results for converted output for classic displays, so working with desktop wallpaper is a good skill-set to develop. Developing a “good eye” for photography and art is also essential to making this all work out.   

 

Framing a full screen image in some way, whether it is cropped to fill the whole screen, or padded to fill part of the screen, is very much a matter of combining personal preference with your presentation requirements. How this will all work out also depends on how the “Original” input image is laid out in the first place combined with how you want it laid out for conversion. But in the first place, if your “Original” input image is high resolution desktop wallpaper for a modern display, it may have been left or right aligned with the opposite side filled with unimportant “stuff”; this is sometimes the case with desktop wallpaper laid-out to suit a range of horizontal resolutions with the same image. Generally, desktop wallpaper is centred and cropping or padding can be automated.

 

Just as a good working knowledge of the art of image composition is needed to select an “Original” input image for conversion, and to know whether to crop or pad the image, knowing the science and the methods, and understanding the workflow of image processing is also essential to making this all work out.

 

At the root of it all is making sure that converted images are in proportion when they are displayed on a classic display, and this is why it is so important that the very first thing you do is crop or pad the “Original” input image to a 4:3 DAR, (followed by saving to a “raw” BMP image format to preserve all available color information, before doing anything else at all).

 

So if you are converting any image that has been created on a modern square pixel display for conversion to a Classic display, your first step will be to crop (or pad) your “Original” input image to a 4:3 resolution and save to a “raw” format before down-scaling. If you are using one of my converters, you generally need to save to an unadorned Windows “Version 3” 24-bit BMP format. Your next step will be to down-scale to the native resolution of the Classic display adapter. If you are converting to 320 x 200 Apple IIgs SHR screen images, you will scale to a 320 x 200 input image, and generally, if you are converting to a 140 x 192 Apple II Double Hi-Res (DHGR) screen image, you will scale to 140 x 192.

 

Step One – Cropping and Padding the Input Image

 

In order to convert today’s square pixel images (with a pixel aspect ratio (PAR) of 1:1) proportionally to most vintage displays (with a display aspect ratio (DAR) of 4:3), cropping is done first. The image is then saved in a raw BMP format to preserve color information. If the height is more than 75% of the width, then the height must be cropped to 75% of the width. Multiply the width by 0.75 to determine the cropped height. If the height is less than 75% of the width, then the width must be cropped to 133% of the height. Multiply the height by 1.333 to determine the cropped width. 

 

If the square pixel image already has a storage aspect ratio (SAR) of 4:3, cropping is not required. You may also choose to pad the input image to a 4:3 aspect ratio, instead of cropping.

 

If the “original” input image is a full screen image that originated on a “vintage” display that does not have square pixels, (like the 640 x 350 EGA display or the 320 x 200 MCGA display), then cropping (or padding) is not required.    

 

Manual Cropping

 

When an image needs to be manually cropped, it is generally more efficient for the average person to use use interactive graphics editing software to visually crop an area of an “original” input image, then to subsequently save the cropped area to a non-lossy “raw” BMP format. However, some people, especially Linux users, programmers and “power users”, may work very efficiently from the command line, so may wish to explore ImageMagick as an alternative to cropping in a “fancy” graphics editor. ImageMagick can be used to crop an image manually and provides many cropping options.

 

As noted above, it is more efficient for everyone to automatically crop (or pad) images that are centered and do not have unwanted areas that need to be avoided.    

 

Unwanted parts of the input image can be cut-out by cropping any “clean” area to an aspect ratio of 4:3. Cropping (and subsequent saving to a non-lossy “raw” BMP format) can be done in variety of graphics editors, including The GIMP and Windows Paint, keeping in mind that the editor must be able to properly interpret the colors in the “original” input image, and after cropping the “orginal” input image must be saved to (“exported to”) a “non-lossy” 24-bit BMP format.

 

 

Automated Cropping

 

Manually cropping and saving to a raw cropped image in BMP format can be tedious, especially when converting a large number of files. ImageMagick can be called from a Windows Batch File or a Unix-like Shell Script to automate the cropping process. In order to preserve all the original color information possible, it is best to crop and save a lossy format like a jpeg to a non-lossy BMP before scaling. But ImageMagick does not currently support an arbitrary cropping command based on aspect ratio. Suggested “work-a-rounds” from the ImageMagick Forum involve scaling and padding as part of the operation, and form the basis for the examples that follow. .

 

Mass Cropping of Identical Size Images

 

Mass cropping of identical size images can be done as shown below.

 

Batch File Example

 

@echo off

REM crop1440.bat - center-crop jpeg 1920 x 1080 hd wallpaper to 4:3 aspect BMP

REM set path to ImageMagick below

REM for ImageMagick version 6.9 use the following

REM set MAGICK=c:\IM\convert

REM for ImageMagick version 7 use the following

set MAGICK=c:\IM\magick

if not exist jpg\*.* mkdir jpg >NUL

for %%f in (*.jpg) do call %MAGICK% %%f -gravity center -crop 1440x1080+0+0 -define format:BMP %%~nf.bmp

cd jpg

if exist ..\*.jpg move ..\*.jpg . > NUL

cd ..

 

Shell Script Example

 

#!/bin/sh

# crop1440.sh - center-crop jpeg 1920 x 1080 hd wallpaper to 4:3 aspect BMP

# set path to ImageMagick below

# for ImageMagick version 6.9 use the following

# MAGICK="c:/IM/convert"

# for ImageMagick version 7 use the following

MAGICK="c:/IM/magick"

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9 use the following

# MAGICK="/usr/bin/convert"

# for ImageMagick version 7 use the following

# MAGICK="/usr/bin/magick"

criteria="*.jpg"

if ls ./*.jpg 1> /dev/null 2>&1 ; then

  if [ ! -e jpg ]; then

    mkdir jpg

  fi

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .jpg)

   $MAGICK $src -gravity center -crop 1440x1080+0+0 -define format:BMP $tgt.bmp

   mv $src ./jpg/

done

fi

 

Mass Cropping of Arbitrary Sized Images

 

The downside of mass cropping of identical size images as shown above is that you would need to write a batch file or shell script for each image size that you are working with, and that might be just as tedious as cropping manually.  A2B provides an output option to create a batch file or shell script as part of the process below which is a little more complicated to understand than the one above, but crops any “original” input file to an aspect ratio of 4:3 then outputs to a raw BMP suitable for scaling.

 

Batch File Examples – aspect43.bat and cropper.bat

 

A hierarchy of batch files is used for this process.

 

Organization Chart

 

 

Aspect43.bat (shown below) is executed by the Windows user using a mouse-click in Explorer or typed in a command window. It calls cropper.bat.

 

@echo off

REM aspect43.bat - center-crop all images to 4:3 aspect BMP

REM calls cropper.bat to do so for each individual image

set CROP=CROP

REM optionally pad all images to 4:3 aspect BMP

if "%1" == "pad" set CROP=%1

if "%1" == "PAD" set CROP=%1

if "%1" == "" goto BEGIN

REM optionally set crop geometry to other gravities (N,S,E,W)

set CROP=%1

:BEGIN

if not exist jpg\*.* mkdir jpg >NUL

for %%f in (*.jpg) do call cropper.bat %%f %%~nf %CROP%

for %%f in (*.png) do call cropper.bat %%f %%~nf %CROP%

for %%f in (*.gif) do call cropper.bat %%f %%~nf %CROP%

cd jpg

if exist ..\*.jpg move ..\*.jpg . > NUL

if exist ..\*.png move ..\*.png . > NUL

if exist ..\*.gif move ..\*.gif . > NUL

cd ..

REM this is the end

 

Cropper.bat (shown below) doesn’t care what image format that a parent process like aspect43.bat feeds it as long it is a format that ImageMagick can convert to a BMP file.

 

@echo off

REM cropper.bat - center-crop or pad image to 4:3 aspect BMP

REM called from aspect43.bat to center-crop each individual image

REM called from pad43.bat to pad each individual image

if "%1" == "" goto ENDER

REM set default method to crop

set METHOD=a43b

REM alternately for pillarboxed or letterboxed padding set method to pad

if "%3" == "PAD" set METHOD=p43b

if "%3" == "pad" set METHOD=p43b

REM alternately set crop geometry to gravities other than center (default)

if "%3" == "N" set METHOD=a43bNorth

if "%3" == "n" set METHOD=a43bNorth

if "%3" == "S" set METHOD=a43bSouth

if "%3" == "s" set METHOD=a43bSouth

if "%3" == "E" set METHOD=a43bEast

if "%3" == "e" set METHOD=a43bEast

if "%3" == "W" set METHOD=a43bWest

if "%3" == "w" set METHOD=a43bWest

REM set paths below

set A2B=..\a2b

rem for ImageMagick version 6.9 use the following

rem set MAGICK=c:\IM\convert

rem set IDENTIFY=c:\IM\identify

rem for ImageMagick version 7 use the following

set MAGICK=c:\IM\magick

set IDENTIFY=c:\IM\magick identify

REM redirect output from ImageMagick identify to a temporary id file for this image

call %IDENTIFY% %1 > %2.id

REM call A2B to use the id file to write a temporary batch file for this image

call %A2B% %1 %METHOD%

call %2.bat %MAGICK% %1 %2

REM clean-up the temporary files

del %2.bat

del %2.id

:ENDER

REM this is the end

 

Work Files

 

Typical temporary work files that are created by cropper.bat are shown below. There is really nothing fancy about them, and they simply hive-off the cropping task for the individual image and are deleted as soon as after they are used. The typical temporary id file listing is followed by the typical temporary cropping batch written by A2B from the id file and executed in cropper.bat.

 

birdseye01.jpg JPEG 1920x1080 1920x1080+0+0 8-bit sRGB 909KB 0.000u 0:00.000

 

@echo off

%1 %2 -gravity center -crop 1440x1080+0+0 -define format:BMP %3.bmp

 

 As you can see there isn’t anything particularly hard being done here… I am just working around ImageMagick’s way of doing things to make absolutely sure that the cropping of images occurs prior to the scaling so that all possible color information is available to the scaling algorithm. Writing batch files in Windows and shell scripts in Unix-like systems like Linux and OSX are simply a matter of using your operating system, and some utilities that don’t have fancy menus.    

 

Shell Script Example – aspect43.sh

 

The Shell Script below does the same thing as the two batch files shown above. Because batch files and shell scripts wire-up differently, we “traditionally” use different constructs to write them, so the algorithm is implemented slightly differently.   

 

The following script can be run in a Unix Console or Mac Terminal. OSX users can also run this script by double-clicking in Finder.

 

#!/bin/sh

# aspect43.sh - center-crop all images to 4:3 aspect BMP (default usage)

# optional usage "aspect43.sh PAD" - pad all images to 4:3 aspect BMP

 

# set path to ImageMagick binaries below

# for ImageMagick version 6.9 use the following

# MAGICK="c:/IM/convert"

# IDENTIFY="c:/IM/identify"

# for ImageMagick version 7 use the following

MAGICK="c:/IM/magick"

IDENTIFY="c:/IM/magick identify"

 

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9 use the following

# MAGICK="/usr/bin/convert"

# IDENTIFY="/usr/bin/identify"

# for ImageMagick version 7 use the following

# MAGICK="/usr/bin/magick"

# IDENTIFY="/usr/bin/magick identify"

 

# set path to A2B converter below

A2B="C:/SHR/A2B2016/a2b"

# For most modern Linux distributions, consider locating A2B in: /usr/bin/ (see below)

# A2B="/usr/bin/a2b"

 

# default usage

method="a43s"

# optional usage

if [ ! -z "$1" ]; then

  if [ "$1" == "PAD" ]; then

    method="p43s"

  fi 

  if [ "$1" == "pad" ]; then

    method="p43s"

  fi   

fi

 

criteria="*.jpg"

if ls ./*.jpg 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .jpg)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

criteria="*.png"

if ls ./*.png 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .png)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

criteria="*.gif"

if ls ./*.gif 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .gif)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

 

# this is the end

 

You probably won’t need to modify the script above very much to work for you provided you put things in the right place in your filing system and set your permissions properly. What you will need to do is modify the paths to the binaries to be used on your system. I do not know if the chmod command in the script above will be necessary for the permissions on your particular Unix-like system, so that can be an adventure for some users.

 

Work Files

 

The temporary work files for Unix-like systems created in the shell script above are essentially the same as those created by cropper.bat for Windows systems. The typical temporary id file listing should be exactly the same and the typical temporary cropping batch written by A2B from the id file and executed in the script above is below:

 

#!/bin/sh

$1 $2 -gravity center -crop 1440x1080+0+0 -define format:BMP $3.bmp

 

Editing Input Images

 

Editing an input image is generally done before scaling. Before you edit, save the original input file to a “raw” 24-bit BMP file to avoid color loss.

 

The “Original” input image for the converted 320 x 200 Apple IIgs SHR screen image example output below began as a square pixel 3840 x 2160 Ultra HD jpeg image with 164,874 unique colors downloaded as desktop wallpaper from Google Images. The Google Images thumbnail of this wallpaper is 300 x 168 x 10,306 unique colors. The wallpaper is derived from an edited photographic work called “Little Hikers” by NYC photographer Mike Stillwell.

 

After downloading, the wallpaper was cropped to 2880 x 2160 (a 4:3 image aspect ratio) and subsequently saved to a “raw” 24-bit BMP file with 161,814 colors using ImageMagick. The unscaled raw BMP was then scaled to a rectangular pixel 320 x 200 x 24-bit BMP with 17,437 unique colors using ImageMagick. The text was then added and the 320 x 200 BMP re-saved in Windows Paint with 17,655 unique colors. Finally, the A2B converter was used to convert the 320 x 200 x 24-bit BMP to the SHR screen image examples below, with quantized palettes by ImageMagick used by A2B’s External Segmented Palette (ESP) option, and Rec. 709 luma coefficients for nearest color matching, with E-dithered examples using A2B’s default “Buckels” dither.  A2B does conversion using the 24-bit color model and IEE double-precision floating point math; it is not until the native SHR files are written to disk that the converted image is reduced to SHR’s 12-bit color model which selects from only 4096 colors. Unique color counts below (and throughout) are provided for both before and after reducing the finished 24-bit conversions to SHR’s 12-bit color model.

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 105 Unique Apple IIgs Colors (217 Unique 24-bit colors)

200-Palettes Non-dithered – 270 Unique Apple IIgs Colors (1856 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 101 Unique Apple IIgs Colors (204 Unique 24-bit colors)

200-Palettes E-dithered – 227 Unique Apple IIgs Colors (998 Unique 24-bit colors)

 

Adjust the Color Balance before Cropping

 

After saving to a “raw” 2-bit BMP file, do your image adjustments (if any) before you do anything else, to maintain the original overall color balance.

 

If you are using a simple graphics editor and crop or do other edits before balancing, the changes that you have made can degrade the results. Cropping the edges of an image removes colors that may be needed to maintain the overall balance during an adjustment. Adding captions in contrasting or saturated colors that do not exist in the original image prior to adjustments (if any) can also result in degraded results because they widen the effective gamut. Although some fancy editors may incorporate advanced features like layering which can be used to work around problems like this, in general these problems can be avoided in the first place by simply adjusting the “raw” BMP before other operations.

 

Padding the Input Image to 4:3 Aspect Instead of Cropping

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 90 Unique Apple IIgs Colors (230 Unique 24-bit colors)

200-Palettes Non-dithered – 274 Unique Apple IIgs Colors (2213 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 92 Unique Apple IIgs Colors (230 Unique 24-bit colors)

200-Palettes E-dithered – 216 Unique Apple IIgs Colors (1131 Unique 24-bit colors)

 

If you are padding to a 4:3 image aspect ratio, generally black padding works best. Padding should usually be Letterboxed or Pillarboxed. The edges of the padding can be sharpened after scaling if desired to avoid aliasing the padding into the image. Pillarboxing will result in the addition of the padding color to every output palette, leaving only 15 other colors per line to render the output. Windowboxed padding can also be done but will reduce the viewing area of the converted image and is only useful to display a padded screen fragment.  

 

Automated Mass Padding instead of Cropping

 

Widescreen images that are cropped to fill the SHR screen may not appeal to everyone because part of the original image is lost. Portrait mode images may also be better-off padded for the same reason. Padding individual images is a very time consuming process, so if you need to pad original input images to accommodate the aspect ratio of 4:3 instead of cropping, you will likely want to try using an automated process to see how that works for you.

 

Batch File Listing – pad43.bat

 

The following batch file automates the padding process. It is almost the same as aspect43.bat with minor changes, but since it is necessary to crop groups of images and pad groups of images separately, it is also necessary to have an entirely separate batch file, considering we hardcore Windows users want to click-on our conversion batches with our mice to avoid typing as much as possible; it is better form to hide mutually exclusive behaviour in separate wrappers rather than force a Windows user to type command line arguments, otherwise we could have just used one batch file with a padding switch command-line option, but since we have mice, we may as well use them.

 

@echo off

REM pad43.bat - pad all images to 4:3 aspect BMP

REM calls cropper.bat to do so for each individual image

if not exist jpg\*.* mkdir jpg >NUL

for %%f in (*.jpg) do call cropper.bat %%f %%~nf PAD

for %%f in (*.png) do call cropper.bat %%f %%~nf PAD

for %%f in (*.gif) do call cropper.bat %%f %%~nf PAD

cd jpg

if exist ..\*.jpg move ..\*.jpg . > NUL

if exist ..\*.png move ..\*.png . > NUL

if exist ..\*.gif move ..\*.gif . > NUL

cd ..

REM this is the end   

 

Obviously this type of batch file is easily extended to accommodate additional graphics file formats. There is no need to list cropper.bat here again since it was previously listed with aspect43.bat and works for both pad43.bat (above) and aspect43.bat. It is terribly important when setting-up these general automation batch files or shell scripts to mirror the actual workflow and to balance that with a high level of reuse so your computer doesn’t end-up with a bunch of messy stuff lying all over.

 

Work Files

 

Padding an image using ImageMagick is a little different than cropping an image. There are two common scenarios as previously noted; letterboxed padding for widescreen output and pillarboxed padding for portrait output. The typical temporary id file output from ImageMagick’s identify is listed below for each:

 

birdseye01.jpg JPEG 1920x1080 1920x1080+0+0 8-bit sRGB 909KB 0.000u 0:00.000

MonaLisa.jpg JPEG 2048x2048 2048x2048+0+0 8-bit sRGB 2.048MB 0.000u 0:00.000

 

The temporary batch file output produced by A2B for each of the above is listed below:

 

@echo off

%1 %2 -gravity center -background black -extent 1920x1920 -crop 1920x1440+0+0 +repage -define format:BMP %3.bmp

 

@echo off

%1 %2 -gravity center -background black -extent 2730x2730 -crop 2730x2048+0+0 +repage -define format:BMP %3.bmp

 

Obviously the idea behind padding is the same as doing it manually except that the arithmetic is done for you.

 

Shell Script Listing – pad43.sh

 

The shell script below is functionally equivalent to the batch file above, and is almost a copy of the shell script listed previously for cropping.

 

#!/bin/sh

# pad43.sh - pad all images to 4:3 aspect BMP (default usage)

# optional usage "pad43.sh CROP" - center-crop all images to 4:3 aspect BMP

 

# set path to ImageMagick binaries below

# for ImageMagick version 6.9 use the following

# MAGICK="c:/IM/convert"

# IDENTIFY="c:/IM/identify"

# for ImageMagick version 7 use the following

MAGICK="c:/IM/magick"

IDENTIFY="c:/IM/magick identify"

 

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9 use the following

# MAGICK="/usr/bin/convert"

# IDENTIFY="/usr/bin/identify"

# for ImageMagick version 7 use the following

# MAGICK="/usr/bin/magick"

# IDENTIFY="/usr/bin/magick identify"

 

# set path to A2B converter below

A2B="C:/SHR/A2B2016/a2b"

# For most modern Linux distributions, consider locating A2B in: /usr/bin/ (see below)

# A2B="/usr/bin/a2b"

 

# default usage

method="p43s"

# optional usage

if [ ! -z "$1" ]; then

  if [ "$1" == "CROP" ]; then

    method="a43s"

  fi 

  if [ "$1" == "crop" ]; then

    method="a43s"

  fi   

fi

 

criteria="*.jpg"

if ls ./*.jpg 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .jpg)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

criteria="*.png"

if ls ./*.png 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .png)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

criteria="*.gif"

if ls ./*.gif 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .gif)

   $IDENTIFY $src > $tgt.id

   $A2B $src $method

   chmod 777 $tgt.sh

   ./$tgt.sh $MAGICK $src $tgt

   rm $tgt.id

   rm $tgt.sh

   mv $src ./jpg/

done

fi

 

# this is the end

 

Work Files

 

The typical temporary shell scripts created by A2B are listed below. These are equivalent to the typical batch files in the preceding batch file listing. The id files in the batch file listing are identical so there is no need to list them here again. 

 

#!/bin/sh

$1 $2 -gravity center -background black -extent 1920x1920 -crop 1920x1440+0+0 +repage -define format:BMP $3.bmp

 

#!/bin/sh

$1 $2 -gravity center -background black -extent 2730x2730 -crop 2730x2048+0+0 +repage -define format:BMP $3.bmp

 

For the curious, the A2B source code that writes these tiny temporary shell scripts and their equivalent batch files is listed next.

 

A2B Source Code Listing – Cropping and Padding Script Output for ImageMagick Automation

 

A2B was not written to be used in place of existing utilities like ImageMagick that work wonderfully well, but to lever them to do things like convert modern graphics to Apple IIgs output that is generally better than anything that was done before.

 

The cropping and padding batch files and shell scripts listed previously depend on ImageMagick to process original input images prior to scaling for A2B’s SHR output. A2B provides a variety of Apple II graphics output, and in addition also provides several other types of handy output to assist in the preparation of Apple II graphics conversion. The following listing is the function from A2B that parses the ImageMagick identify output and does the cropping or padding calculations and finally outputs the temporary batch files or scripts required for the ImageMagick convert utility to do the cropping or padding itself.

 

/*

#define GRAVITY_CENTER    0

#define GRAVITY_EAST      1

#define GRAVITY_NORTHEAST 2

#define GRAVITY_NORTH     3

#define GRAVITY_NORTHWEST 4

#define GRAVITY_SOUTHEAST 5

#define GRAVITY_SOUTH     6

#define GRAVITY_SOUTHWEST 7

#define GRAVITY_WEST      8

*/

#define NUM_GRAVITIES     9

 

/* gravity options for cropped output - center (typical) */

char *geometry[] = {

"Center",

"East",

"NorthEast",

"North",

"NorthWest",

"SouthEast",

"South",

"SouthWest",

"West",

NULL};

 

char *gravity = "center";

 

/* command line helper function to set ImageMagick geometry for gravity option */

void SetMagickAspectScript(char *wordptr)

{

    int idx;

 

    if (wordptr[0] != (char) 0) {

        for (idx = 0;idx < NUM_GRAVITIES;idx++) {

            if (cmpstr(wordptr,geometry[idx]) == SUCCESS) {

                gravity = (char *) &geometry[idx][0];

                return;

            }

        }

    }

}

 

 

/* args are image file name, type of output 0 or 1 (.bat or .sh),

   and whether output is cropped 0 or padded 1 */

int MakeMagickAspectScript(char *name,int script, int pad)

{

    FILE *fp, *fp2=NULL;

    char buf[128], c, d, idfile[256], outfile[256];

    int i, j, status = 1;

    float fwidth, fheight;

    int width, height, cropwidth, cropheight, xtent;

 

    /* use image file base name for id file name and batch file or script file name */

    strcpy(idfile,name);

    strcpy(outfile,name);

    j = 999;

    for (i=0;name[i]!=(char)0;i++){

        if (name[i] == '.')j=i;

    }

 

    /* the image file name must have an extension */

    if (j==999) return status;

    idfile[j] = outfile[j]=(char)0;

 

    /* the id file must already exist */

    strcat(idfile,".id");

    fp = fopen(idfile,"r");

    if (fp == NULL) return status;

 

    if (script == 0) strcat(outfile,".bat");

    else strcat(outfile,".sh");

 

    for (;;) {

        if (NULL == fgets(buf, 128, fp)) {

            fclose(fp);

            break;

        }

        nocr(buf);

        /* this parser is really simplistic... it uses the first widthxheight string preceded by a space...

           it will probably usually work since we don't usually put widthxheight strings in filenames */

        width = height = 0;

        d = (char)0;

        for (i=0;buf[i]!=(char)0;i++){

            if (d == (char)32) {

                width = atoi((char *)&buf[i]);

            }

            c = buf[i];

            if (c=='x' && width > 0) {

                if (d > (char)47 && d < (char)58) {

                    height = atoi((char *)&buf[i+1]);

                    if (height > 0) break;

                }

            }

            d = c;

        }

        if (width == 0) break;

        if (height == 0) break;

        if (pad == 0) {

            /* cropping (not padding) */

            /* for widescreen images trim both sides, the height remains the same */

            fwidth = (float)1.3334 * height;

            cropwidth = (int)fwidth;

            if (cropwidth > width) {

                /* if the cropping width is not 1/3 greater than the height, this is a portrait image

                   and must be cropped in the vertical axis only */

                cropwidth = width;

                fheight = (float)0.75 * width;

                cropheight = (int)fheight;

            }

            else {

                cropheight = height;

            }

        }

        else {

            fheight = (float)0.75 * width;

            cropheight = (int)fheight;

            if (cropheight == height) {

               /* if the height is equal to 75% of the width, the output is verbatim (no padding is needed) */

               cropwidth = width;

               pad = 0;

            }

            else if (height < cropheight) {

               /* if the height is less than 75% of the width, the output is letterboxed with padding above and below */

               xtent = cropwidth = width;

            }

            else {

               /* if the height is greater than 75% of the width, the output is pillarboxed with padding on the sides */

               cropheight = height;

               fwidth = (float)1.3334 * height;

               xtent = cropwidth = (int)fwidth;

            }

        }

        fp2 = fopen(outfile,"w");

        if (NULL == fp2) break;

 

        if (script == 0) {

            /* batch file output */

            fprintf(fp2,"@echo off\n");

            if (pad == 0) {

                /* %MAGICK% %%f -gravity center -crop 1440x1080+0+0 -define format:BMP %%~nf.bmp */

                fprintf(fp2,"%%1 %%2 -gravity %s -crop %dx%d+0+0 -define format:BMP %%3.bmp\n",gravity,cropwidth,cropheight);

            }

            else {

               /* letterbox */

               /* %MAGICK% %%f -gravity center -background black -extent 1920x1920 -crop 1920x1440+0+0 +repage -define format:BMP %%~nf.bmp */

               /* pillarbox */

               /* %MAGICK% %%f -gravity center -background black -extent 2730x2730 -crop 2730x2048+0+0 +repage -define format:BMP %%~nf.bmp */

               fprintf(fp2,

               "%%1 %%2 -gravity %s -background black -extent %dx%d -crop %dx%d+0+0 +repage -define format:BMP %%3.bmp\n",

               gravity,xtent,xtent,cropwidth,cropheight);

 

            }

        }

        else {

            /* shell script output */

            fprintf(fp2,"#!/bin/sh\n");

            if (pad == 0) {

                /* $MAGICK $src -gravity center -crop 1440x1080+0+0 -define format:BMP $tgt.bmp */

                fprintf(fp2,"$1 $2 -gravity %s -crop %dx%d+0+0 -define format:BMP $3.bmp\n",gravity,cropwidth,cropheight);

            }

            else {

               fprintf(fp2,

               "$1 $2 -gravity %s -background black -extent %dx%d -crop %dx%d+0+0 +repage -define format:BMP $3.bmp\n",

               gravity,xtent,xtent,cropwidth,cropheight);

 

            }

        }

        status = 0;

    }

    fclose(fp);

    if (NULL != fp2) fclose(fp2);

 

    return status;

}

 

There’s lots of software developers in the Apple II community who are quite adept at writing batch files or shell scripts that will look at this stuff and wonder why I did not just write one large conversion batch or script and let it go at that, and there are users of software in the Apple II community who want menus rather than batch files and scripts just to “kick the tires” on this converter. Most of this nonsense isn’t about doing any of those things; it’s about establishing a workflow that you can take forward on your own, realizing there never was much of a real need for SHR conversions of continuous tone images in the past, and they are just as pointless today. A2B’s ESP option is really just a small part of what the converter can do, but it provides you with the same opportunity as it does for me, and that is to look at what we might have been able to do 30 years ago with the Apple IIgs display if a production oriented workflow had been combined with ImageMagick and modern graphics content and techniques. We do not need to have menus for that, and we need to properly decompose this experiment to have any fun with it at all. It’s simply entertainment of a somewhat educational nature.      

 

Step Two – Scaling the Cropped Input Image

 

Following Step One above, the square pixel raw input image now has a screen aspect ratio of 4:3, and must be scaled to the screen resolution, and again saved to a raw format to preserve color accuracy. This ensures that the pixel aspect ratio is proportional to the vintage display. A good quality scaling algorithm must be used to preserve color accuracy and prevent color loss as much as possible. For a 320 x 200 SHR input image, scale to 320 x 200. (Conversions to other vintage display resolutions with a screen aspect of 4:3 can also use the input image created in Step One. For a target 140 x 192 DHGR input image, scale to 140 x 192.)

 

Scaling in a Windows Batch File using ImageMagick

 

Scaling of full-screen images is generally automated by calling ImageMagick in a batch file or a script.

 

Adding Captions to A Scaled Input Image

 

To avoid aliasing of fonts as much as possible, captions can be created in Monochrome and added to the scaled version of the raw BMP input image using a transparent paste just prior to conversion to SHR output. This is a manual step. If you want a caption with an aliased font, you will generally get your best results by adding captions to the raw BMP input image before scaling, but after color adjustments if any.

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 89 Unique Apple IIgs Colors (231 Unique 24-bit colors)

200-Palettes Non-dithered – 273 Unique Apple IIgs Colors (2214 Unique 24-bit colors)

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 88 Unique Apple IIgs Colors (215 Unique 24-bit colors)

200-Palettes E-dithered – 217 Unique Apple IIgs Colors (1131 Unique 24-bit colors)

 

The magnified Apple IIgs SHR output above shows the results of adding a non-aliased caption to a scaled input image just prior to conversion. The font is a monochrome sans serif 8 point Arial TrueType similar to Helvetica. It was added in Windows Paint. By the way, I can’t help agreeing with The Hulk. The A2B converter works with 24-bit color depth during conversion up until the time the Apple IIgs output is produced. During the time that the Apple IIgs was in wide use, GIF file converters were pretty standard. A GIF file can’t even hold more than 256 colors. The non-dithered 200 palette conversion above has 2214 unique 24-bit colors which reduce to 273 Apple IIgs colors; an impossible number of colors for a GIF file to even provide.    

 

Step Three – Slicing the Input Image into 16-color Palette Files

 

Slicing of full-screen images is generally automated by calling the ImageMagick Convert utility in a batch file or a script. Slices must correspond to the A2B converter’s Palette Segments and follow a specific naming convention. Each slice is individually quantized to 16 colors for each Palette Segment. Slices are saved in PCX Version 5 256-color file format, and the 16 color palettes from the slices are loaded by A2B and used to convert the scaled input image.

 

The reason that I chose to use the now-obsolete ZSoft PCX format was for my own convenience during development, including the fact that the palette is easy to read, the file format will never change, the image data is run-length encoded so doesn’t use much space, and while the image data is not used by A2B, it can be viewed if need be in ImageMagick’s IMDisplay utility or in an editor like The GIMP or my own ClipShop utility.   

 

Step Four – Converting to SHR

 

Converting of full-screen images is generally automated by calling the A2B converter in a batch file or a script. The External Segmented Palette files in PCX format described in Step Three are loaded and used at this time. Primary Output is in 320 x 200 SHR format.

 

1-Palette Non-dithered – 16 Unique Apple IIgs Colors

16-Palettes Non-dithered – 96 Unique Apple IIgs Colors

200-Palettes Non-dithered – 284 Unique Apple IIgs Colors

1-Palette E-dithered – 16 Unique Apple IIgs Colors

16-Palettes E-dithered – 95 Unique Apple IIgs Colors

200-Palettes E-dithered – 229 Unique Apple IIgs Colors

 

Step Five – Creating an SHR Slideshow

 

Converted 320 x 200 SHR screen image output produced from continuous tone input images is generally intended for use in an Apple IIgs slide-show. There is really little other practical purpose for these files. However, regardless of what you use your conversions for; you will still need to place them on an Apple IIgs disk or disk image for use on an Apple IIgs or an Apple IIgs emulator. This is not meant to be an exhaustive tutorial about all of your options, and is just an overview of what I do to create a slideshow in Windows to put on a disk image for the Kegs32 emulator using Ciderpress.

 

It is probably important to note that I use Microdrives and Compact Flash (CF) Cards to port Apple II programs to a real Apple II. Ciderpress supports transferring files and even whole volumes directly to a CF card for this purpose, from disk images or other volumes like a Windows drive. This is not meant to be a Ciderpress tutorial either. 

 

The Local Slideshow and Review of Converted Output

 

It’s a lot of work to port a slideshow to a real Apple II (or even to a disk image) with the intent of editing it there. It’s easiest to fine-tune the slideshow on your modern working computer first, and finish your edits and deletions, etc. before porting. The following batch files and equivalent shell scripts are what I use in Windows to build my local slideshow before I port it across…

 

Batch File Listing – magall.bat

 

@echo off

REM magall.bat - post process the output from the A2B converter

REM use ImageMagick to make double scaled preview files for review in a separate subdirectory

REM these can be viewed as a slide-show under Windows

REM copy SHR output to a separate subdirectory (with no additional files) for preparing Apple IIgs slide-shows

REM CiderPress can then be used more easily to place SHR files on an Apple IIgs Disk Image

REM set path to ImageMagick below

REM for ImageMagick version 6.9 use ImageMagick's convert utility

REM set MAGICK=C:\IM\convert

REM for ImageMagick version 7 use the following

set MAGICK=C:\IM\magick

cd SH30709raw

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.shr#C10000) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

cd SH32709raw

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.sh2#C10000) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

cd SH33709raw

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.sh3#C10002) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

cd sh33709

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.sh3#C10002) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

cd sh32709

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.sh2#C10000) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

cd sh30709

if not exist png\*.* mkdir png >NUL

if not exist shr\*.* mkdir shr >NUL

for %%f in (*_proc.bmp) do if not exist png\%%~nf.png call %MAGICK% %%f -magnify -define format:PNG png\%%~nf.png

for %%f in (*.shr#C10000) do if not exist SHR\%%f copy %%f shr\%%f > NUL

cd ..

REM this is the end

 

Shell Script Listing – magall.sh

 

#!/bin/sh

# magall.sh - post process the output from the A2B converter

# use ImageMagick to make double scaled preview files for review in a separate subdirectory

# these can be viewed as a slide-show under Windows

# copy SHR output to a separate subdirectory (with no additional files) for preparing Apple IIgs slide-shows

# CiderPress can then be used more easily to place SHR files on an Apple IIgs Disk Image

 

# set paths to ImageMagick below

# for ImageMagick version 6.9 use ImageMagick's convert utility

# MAGICK="C:/IM/convert"

# for ImageMagick version 7 use the following

MAGICK="C:/IM/magick"

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9

# MAGICK="/usr/bin/convert"

# for ImageMagick version 7

# MAGICK="/usr/bin/magick"

 

cd SH30709raw

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

cd SH32709raw

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

cd SH33709raw

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

cd sh33709

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

cd sh32709

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

cd sh30709

if [ ! -e png ]; then

     mkdir png

fi  

if [ ! -e shr ]; then

     mkdir shr

fi  

if ls ./*_proc.bmp 1> /dev/null 2>&1 ; then

criteria="*_proc.bmp"

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   if [ ! -e ./png/$src ]; then

     $MAGICK $src -magnify -define format:PNG png//$tgt.png

   fi

 done

criteria="*.SH*"

for i in $( ls $criteria); do

   src=$i

   if [ ! -e ./shr/$src ]; then

     cp $src shr/$src

   fi

 done

fi

cd ..

# this is the end

 

Removing Unwanted Conversions

 

Converting modern graphics to Apple IIgs SHR files will generate lots of unwanted conversions and other artifacts, and will leave you with quite a mess if you don’t remove these. The following batch files and shell scripts are used for that purpose. Like the other batch files and shell scripts in this document, these are not intended as stellar examples of batch file or shell script programming… they are simply what I use and I am sharing these with you without any warranty or liability whatsoever, and they don’t come with an undo buffer… use at your own risk.

 

You should note that kill.bat and kill.sh shown below both accept a partial basename as a commandline argument as search criteria for file removal. This allows for groups of similarly named files to be removed altogether… but this preference of mine must be used with caution. Also you should note that the general removal of files has been kept separate from the removal of palette directories.

 

Batch File Listings for Removing Unwanted Conversions

 

@echo off 

REM kill.bat - house-cleaning batch file

REM cleans unwanted input and output from working directory

REM must be run from the command line

REM killpalette.bat must also be run after kill.bat to remove unused external palette directories

if "%1" == "" goto ENDER

dir %1*.* /s /b > work.txt

for /F %%j in (work.txt) do del %%j

del work.txt

:ENDER

REM this is the end

 

@echo off 

REM killpalette.bat - house-cleaning batch file

REM removes unused palette directories left behind by kill.bat

dir sh0pcx\*.* /b /A:D > work.txt

for /F %%j in (work.txt) do if not exist sh0pcx\%%j\0.pcx rd sh0pcx\%%j

dir sh2pcx\*.* /b /A:D > work.txt

for /F %%j in (work.txt) do if not exist sh2pcx\%%j\0.pcx rd sh2pcx\%%j

dir sh3pcx\*.* /b /A:D > work.txt

for /F %%j in (work.txt) do if not exist sh3pcx\%%j\0.pcx rd sh3pcx\%%j

del work.txt

REM this is the end

 

Shell Script Listings for Removing Unwanted Conversions

#!/bin/sh

# kill.sh - house-cleaning script

# cleans unwanted input and output from working directory

# must be run from the command line

# killpalette.sh must also be run after kill.sh to remove unused external palettes

if [ ! -z "$1" ]; then

    find -iname $1* -exec rm {} \;

else

    echo "no args"

fi

# this is the end

 

#!/bin/sh

# killpalette.sh - house-cleaning script

# removes external segmented palette files left-over from deleted images and related output

# then removes the associated palette directory

# if the done directory does not contain a processed bmp, assumes the palettes are no longer needed

cd sh0pcx

for i in $(ls); do

   tgt=$(basename $i)

   if [ ! -e ../done/$tgt.bmp ]; then

       if [ -e ./$tgt/0.pcx ]; then

           rm ./$tgt/*.pcx

       fi  

       rmdir ./$tgt

   fi

   done

cd ..  

cd sh2pcx

for i in $(ls); do

   tgt=$(basename $i)

   if [ ! -e ../done/$tgt.bmp ]; then

       if [ -e ./$tgt/0.pcx ]; then

           rm ./$tgt/*.pcx

       fi  

       rmdir ./$tgt

   fi

   done

cd ..  

cd sh3pcx

for i in $(ls); do

   tgt=$(basename $i)

   if [ ! -e ../done/$tgt.bmp ]; then

       if [ -e ./$tgt/0.pcx ]; then

           rm ./$tgt/*.pcx

       fi  

       rmdir ./$tgt

   fi

   done

cd ..  

# this is the end

 

Process Batch Files and Shell Scripts and the Working Directory Structure

 

A working directory structure is fundamental to keeping any computer work organized and to managing workflow of a relatively non-trivial nature. During the development and testing of the A2B converter, thousands of images were processed using various input and output options which naturally resulted in the directory structure, Naming conventions and the Windows batch files and the equivalent Unix-like Shell Scripts for the workflow that is discussed in this article.

 

The hierarchical model that has been applied consists of:

 

  • Working Directory and Working Subdirectories
  • Palette File Subdirectories
  • Output File Subdirectories
  • Archival Subdirectories for “original” Input Images and Scaled 320 x 200 Input Images that have been processed.

 

In Step One noted above, when the “original” Input Image is cropped manually and then saved to a 24-bit BMP, the “original” input image is then archived in the “jpg” subdirectory before running cvt2bmp.bat (shown below) to scale the input image, and create the conversion palette files.    

 

Step Two – Batch File Source Listing - cvt2bmp.bat

 

@echo off

REM cvt2bmp.bat - uses ImageMagick to produce 320 x 200 Input Files for A2B

 

REM set path to ImageMagick below

REM for ImageMagick version 6.9 use the following

REM set MAGICK=c:\IM\convert

REM for ImageMagick version 7 use the following

set MAGICK=C:\IM\magick

 

if not exist BMP320\*.* mkdir BMP320 >NUL

if not exist ORGBMP\*.* mkdir ORGBMP >NUL

if not exist jpg\*.* mkdir jpg >NUL

 

REM create GIF input files for native mode converters if needed.

REM if not exist gif\*.* mkdir gif >NUL

 

REM assumes that all input files are 4:3 Aspect Ratio

REM accepts jpegs, pngs, gifs, or BMPs as input files

REM converts everything to truecolor BMP before scaling to avoid color loss

for %%f in (*.jpg) do call %MAGICK% %%f -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 %%~nf.bmp

for %%f in (*.png) do call %MAGICK% %%f -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 %%~nf.bmp

for %%f in (*.gif) do call %MAGICK% %%f -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 %%~nf.bmp

cd jpg

if exist ..\*.jpg move ..\*.jpg . > NUL

if exist ..\*.png move ..\*.png . > NUL

if exist ..\*.gif move ..\*.gif . > NUL

cd ..

 

REM create A2B's input files - scaling is done here.

for %%f in (*.bmp) do call %MAGICK% %%f -resize "320x200!" -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 BMP320\%%~nf.bmp

REM create GIF input files for native mode converters if needed.

REM for %%f in (BMP320\*.bmp) do call %MAGICK% %%f -colors 256 -define format:GIF GIF\%%~nfx.gif

cd orgbmp

move ..\*.bmp .

cd ..\bmp320

move *.bmp ..\.

cd ..

 

REM this is the end

 

The batch file above is deliberately self-explanatory. It starts by creating the required subdirectories if they do not exist. These directories are as follows:

 

  • Jpg – Archival Subdirectory for “original” Input Images in jpeg, png, and GIF formats.
  • OrgBmp – Archival Subdirectory for 4:3 aspect “full scale” Input Images in “raw” 24-bit BMP format.
  • Bmp320 – Output file Working Directory for scaled 320 x 200 x 24-bit BMP input files for the A2B converter.

 

Step Two – Shell Script Source Listing - cvt2bmp.sh

 

The shell script below is functionally the same as the batch file above. It was written under Windows XP and tested in the msys shell using the Windows version of ImageMagick, so may need some minor changes to work on a Unix-like system. I wouldn’t expect anyone who is actually using a Unix-like system to have any trouble tweaking this as needed.

 

#!/bin/sh

# cvt2bmp.sh - uses ImageMagick to produce 320 x 200 Input Files for A2B

 

# set path to ImageMagick binaries below

# for ImageMagick version 6.9 use the following

# MAGICK="c:/IM/convert"

# for ImageMagick version 7 use the following

MAGICK="c:/IM/magick"

 

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9 use the following

# MAGICK="/usr/bin/convert"

# for ImageMagick version 7 use the following

# MAGICK="/usr/bin/magick"

 

if [ ! -e BMP320 ]; then

     mkdir BMP320

fi  

if [ ! -e ORGBMP ]; then

     mkdir ORGBMP

fi  

if [ ! -e jpg ]; then

     mkdir jpg

fi  

 

# create GIF input files for native mode converters if needed.

# if [ ! -e gif ]; then

#    mkdir gif

# fi

 

# assumes that all input files are 4:3 Aspect Ratio

# accepts jpegs, pngs, gifs, or BMPs as input files

# converts everything to truecolor BMP before scaling to avoid color loss

 

criteria="*.jpg"

if ls ./*.jpg 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .jpg)

   $MAGICK $src -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 $tgt.bmp

   mv $src ./jpg/

done

fi

criteria="*.png"

if ls ./*.png 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .png)

   $MAGICK $src -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 $tgt.bmp

   mv $src ./jpg/

done

fi

criteria="*.gif"

if ls ./*.gif 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .gif)

   $MAGICK $src -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 $tgt.bmp

   mv $src ./jpg/

done

fi

 

# create A2B's input files - scaling is done here.

criteria="*.bmp"

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria);

do

   src=$i

   tgt=$(basename $i .bmp)

   $MAGICK $src -resize "320x200!" -type truecolor -units PixelsPerInch -density 72 -compress None -depth 24 -define format:BMP3 BMP320//$tgt.bmp

   # create GIF input files for native mode converters if needed.

   # $MAGICK $src -colors 256 -define format:GIF gif//"$tgt"x.gif

done

mv *.bmp ./ORGBMP/

mv BMP320/*.bmp ./

fi

 

# this is the end

 

Step Four – Batch File Source Listing - Cvt.bat

 

@echo off

REM cvt.bat - creates 6 variations of 320 x 200 SHR files using A2B and external segmented palettes

 

REM set path to A2B converter below

set A2B=..\a2b

 

if not exist SH30709\*.* mkdir SH30709 >NUL

if not exist SH32709\*.* mkdir SH32709 >NUL

if not exist SH33709\*.* mkdir SH33709 >NUL

if not exist SH30709raw\*.* mkdir SH30709raw >NUL

if not exist SH32709raw\*.* mkdir SH32709raw >NUL

if not exist SH33709raw\*.* mkdir SH33709raw >NUL

 

if not exist todo\*.* mkdir todo >NUL

if not exist done\*.* mkdir done >NUL

 

REM make External Segmented Palettes using ImageMagick's Convert Utility

call slicer.bat

 

REM Call A2B to create SHR files

for %%f in (*.bmp) do call %A2B% %%f SH30709\%%f dr m2s t PIMsh0pcx\%%~nf\foo sum l709 >NUL

for %%f in (*.bmp) do call %A2B% %%f SH32709\%%f dr m2s t PIMsh2pcx\%%~nf\foo sum l709 >NUL

for %%f in (*.bmp) do call %A2B% %%f SH33709\%%f dr m2s t PIMsh3pcx\%%~nf\foo sum l709 >NUL

 

for %%f in (*.bmp) do call %A2B% %%f SH30709raw\%%f m2s t PIMsh0pcx\%%~nf\foo sum l709 >NUL

for %%f in (*.bmp) do call %A2B% %%f SH32709raw\%%f m2s t PIMsh2pcx\%%~nf\foo sum l709 >NUL

for %%f in (*.bmp) do call %A2B% %%f SH33709raw\%%f m2s t PIMsh3pcx\%%~nf\foo sum l709 >NUL

 

cd done

move ..\*.bmp .

cd ..

 

REM this is the end

 

You may be wondering why the listing above for “cvt.bat” jumps right to Step Four. This is simply because “slicer.bat” is called from within “cvt.bat” to perform Step Three.

 

You will note that “cvt.bat” adds several more subdirectories to the Working Directory Structure. They are as follows:

 

  • SH30709 – Output File Subdirectory for 1-Palette Dithered SHR Output using Rec. 709 coefficients for closest color
  • SH30709RAW – Output File Subdirectory for 1-Palette Dithered SHR Output using Rec. 709 coefficients for closest color
  • SH32709 – Output File Subdirectory for 16-Palette Dithered SH2 Output using Rec. 709 coefficients for closest color
  • SH32709RAW – Output File Subdirectory for 16-Palette Dithered SH2 Output using Rec. 709 coefficients for closest color
  • SH33709 – Output File Subdirectory for 200-Palette Dithered SH3 Output using Rec. 709 coefficients for closest color
  • SH33709RAW – Output File Subdirectory for 200-Palette Dithered SH3 Output using Rec. 709 coefficients for closest color
  • todo – Working Subdirectory to “park” future “original” images awaiting cropping to keep them out of the Working Directory
  • done – Archival Subdirectory for 320 x 200 x 24-bit BMP files that have been converted to SHR output

 

The A2B command line in “cvt.bat” uses the “M2S” option to create preview output in 320 x 200 24-bit BMP format complete with a second 24-bit BMP containing the final converted 16-color palettes. This is an editing feature. The M2S utility that is provided with A2B can process these two files together after editing to produce a “corrected” conversion in either Apple IIgs screen image format or Apple IIgs APF format.

 

 A2B’s palettes are selected using the “P” option. Initially, A2B only used internal conversion palettes. As A2B evolved, external palette files were added, using the “P” option followed by the palette file name. When the ESP option was added, the “P” option was extended to include the “PIM” variation followed by the ESP palette directory path.           

 

Step Four – Shell Script Source Listing – cvt.sh

 

#!/bin/sh

# cvt.sh - creates 6 variations of 320 x 200 SHR files using A2B and external segmented palettes

 

# set path to A2B converter below

A2B="F:/SHR/A2B2015/a2b"

# For most modern Linux distributions, consider locating A2B in: /usr/bin/ (see below)

# A2B="/usr/bin/a2b"

 

if [ ! -e SH30709 ]; then

     mkdir SH30709

fi  

if [ ! -e SH32709 ]; then

     mkdir SH32709

fi  

if [ ! -e SH33709 ]; then

     mkdir SH33709

fi  

if [ ! -e SH30709raw ]; then

     mkdir SH30709raw

fi  

if [ ! -e SH32709raw ]; then

     mkdir SH32709raw

fi  

if [ ! -e SH33709raw ]; then

     mkdir SH33709raw

fi  

 

if [ ! -e todo ]; then

     mkdir todo

fi  

if [ ! -e done ]; then

     mkdir done

fi

 

# make External Segmented Palettes using ImageMagick

./slicer.sh

 

# Call A2B to create SHR files

criteria="*.bmp"

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

 

   $A2B $src SH30709/$src dr m2s t PIMsh0pcx/$tgt/foo sum l709 > /dev/null

   $A2B $src SH32709/$src dr m2s t PIMsh2pcx/$tgt/foo sum l709 > /dev/null

   $A2B $src SH33709/$src dr m2s t PIMsh3pcx/$tgt/foo sum l709 > /dev/null

 

   $A2B $src SH30709raw/$src m2s t PIMsh0pcx/$tgt/foo sum l709 > /dev/null

   $A2B $src SH32709raw/$src m2s t PIMsh2pcx/$tgt/foo sum l709 > /dev/null

   $A2B $src SH33709raw/$src m2s t PIMsh3pcx/$tgt/foo sum l709 > /dev/null

done

mv *.bmp ./done/

fi

 

# this is the end

 

Step Three – Batch File Listing – slicer.bat

 

@echo off

REM slicer.bat - use ImageMagick to produce External Segment Palette Files for A2B

REM set path to ImageMagick below

REM for ImageMagick version 6.9 use ImageMagick's convert utility

REM set MAGICK=C:\IM\convert

REM for ImageMagick version 7 use the following

set MAGICK=C:\IM\magick

 

REM create directory structure for 16 color image segments

if not exist sh0pcx\*.* mkdir sh0pcx >NUL

REM if not exist sh1pcx\*.* mkdir sh1pcx >NUL

if not exist sh2pcx\*.* mkdir sh2pcx >NUL

if not exist sh3pcx\*.* mkdir sh3pcx >NUL

 

REM segment directories are of the same basename as the bmp being converted

REM the segments themselves are 0.pcx 1.pcx, 2.pcx, etc.

for %%f in (*.bmp) do if not exist sh0pcx\%%~nf mkdir sh0pcx\%%~nf >NUL 

REM for %%f in (*.bmp) do if not exist sh1pcx\%%~nf mkdir sh1pcx\%%~nf >NUL 

for %%f in (*.bmp) do if not exist sh2pcx\%%~nf mkdir sh2pcx\%%~nf >NUL 

for %%f in (*.bmp) do if not exist sh3pcx\%%~nf mkdir sh3pcx\%%~nf >NUL

 

goto BEGIN

 

REM 8-segments for multi-palette for motion video

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\0.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\1.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\2.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\3.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\4.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\5.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\6.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x25+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx\%%~nf\7.pcx

 

:BEGIN

 

REM use the same segments currently used in A2B

 

REM 1-segment for single palette SHR

for %%f in (*.bmp) do call %MAGICK% %%f -dither FloydSteinberg -colors 16 -define format:PCX sh0pcx\%%~nf\0.pcx

 

REM 16-segments for multi-palette

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+187 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\0.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\1.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+162 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\2.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\3.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+137 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\4.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\5.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+112 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\6.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\7.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+87 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\8.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\9.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+62 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\10.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\11.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+37 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\12.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\13.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x13+0+12 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\14.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x12+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx\%%~nf\15.pcx

 

REM 200-segments for brooks

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+199 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\0.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+198 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\1.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+197 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\2.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+196 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\3.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+195 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\4.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+194 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\5.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+193 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\6.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+192 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\7.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+191 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\8.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+190 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\9.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+189 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\10.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+188 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\11.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+187 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\12.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+186 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\13.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+185 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\14.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+184 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\15.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+183 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\16.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+182 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\17.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+181 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\18.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+180 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\19.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+179 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\20.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+178 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\21.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+177 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\22.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+176 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\23.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\24.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+174 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\25.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+173 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\26.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+172 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\27.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+171 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\28.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+170 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\29.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+169 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\30.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+168 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\31.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+167 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\32.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+166 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\33.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+165 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\34.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+164 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\35.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+163 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\36.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+162 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\37.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+161 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\38.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+160 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\39.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+159 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\40.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+158 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\41.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+157 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\42.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+156 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\43.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+155 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\44.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+154 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\45.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+153 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\46.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+152 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\47.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+151 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\48.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\49.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+149 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\50.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+148 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\51.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+147 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\52.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+146 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\53.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+145 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\54.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+144 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\55.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+143 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\56.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+142 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\57.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+141 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\58.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+140 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\59.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+139 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\60.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+138 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\61.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+137 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\62.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+136 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\63.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+135 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\64.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+134 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\65.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+133 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\66.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+132 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\67.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+131 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\68.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+130 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\69.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+129 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\70.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+128 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\71.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+127 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\72.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+126 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\73.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\74.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+124 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\75.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+123 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\76.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+122 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\77.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+121 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\78.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+120 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\79.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+119 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\80.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+118 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\81.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+117 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\82.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+116 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\83.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+115 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\84.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+114 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\85.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+113 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\86.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+112 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\87.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+111 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\88.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+110 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\89.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+109 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\90.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+108 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\91.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+107 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\92.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+106 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\93.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+105 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\94.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+104 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\95.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+103 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\96.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+102 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\97.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+101 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\98.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\99.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+99 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\100.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+98 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\101.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+97 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\102.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+96 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\103.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+95 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\104.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+94 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\105.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+93 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\106.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+92 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\107.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+91 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\108.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+90 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\109.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+89 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\110.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+88 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\111.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+87 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\112.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+86 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\113.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+85 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\114.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+84 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\115.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+83 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\116.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+82 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\117.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+81 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\118.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+80 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\119.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+79 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\120.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+78 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\121.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+77 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\122.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+76 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\123.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\124.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+74 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\125.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+73 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\126.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+72 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\127.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+71 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\128.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+70 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\129.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+69 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\130.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+68 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\131.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+67 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\132.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+66 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\133.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+65 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\134.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+64 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\135.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+63 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\136.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+62 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\137.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+61 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\138.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+60 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\139.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+59 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\140.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+58 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\141.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+57 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\142.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+56 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\143.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+55 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\144.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+54 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\145.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+53 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\146.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+52 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\147.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+51 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\148.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\149.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+49 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\150.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+48 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\151.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+47 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\152.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+46 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\153.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+45 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\154.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+44 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\155.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+43 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\156.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+42 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\157.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+41 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\158.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+40 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\159.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+39 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\160.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+38 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\161.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+37 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\162.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+36 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\163.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+35 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\164.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+34 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\165.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+33 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\166.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+32 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\167.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+31 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\168.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+30 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\169.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+29 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\170.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+28 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\171.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+27 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\172.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+26 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\173.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\174.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+24 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\175.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+23 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\176.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+22 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\177.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+21 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\178.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+20 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\179.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+19 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\180.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+18 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\181.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+17 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\182.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+16 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\183.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+15 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\184.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+14 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\185.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+13 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\186.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+12 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\187.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+11 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\188.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+10 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\189.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+9 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\190.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+8 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\191.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+7 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\192.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+6 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\193.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+5 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\194.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+4 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\195.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+3 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\196.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+2 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\197.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+1 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\198.pcx

for %%f in (*.bmp) do call %MAGICK% %%f -crop 320x1+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx\%%~nf\199.pcx

 

REM this is the end

 

Step Three – Shell Script Listing – slicer.sh

 

#!/bin/sh

# slicer.sh - shell script to produce External Segment Palette Files for A2B

 

# set paths to ImageMagick below

# for ImageMagick version 6.9 use ImageMagick's convert utility

# MAGICK="C:/IM/convert"

# for ImageMagick version 7 use the following

MAGICK="C:/IM/magick"

# For most modern Linux distributions, all ImageMagick binaries are located in: /usr/bin/ (see below)

# for ImageMagick version 6.9

# MAGICK="/usr/bin/convert"

# for ImageMagick version 7

# MAGICK="/usr/bin/magick"

 

# create directory structure for 16 color image segments

if [ ! -e sh0pcx ]; then

     mkdir sh0pcx

fi  

#if [ ! -e sh1pcx ]; then

#    mkdir sh1pcx

#fi 

if [ ! -e sh2pcx ]; then

     mkdir sh2pcx

fi  

if [ ! -e sh3pcx ]; then

     mkdir sh3pcx

fi  

 

# segment directories are of the same basename as the bmp being converted

# the segments themselves are 0.pcx 1.pcx, 2.pcx, etc.

criteria="*.bmp"

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria); do

   tgt=$(basename $i .bmp)

   if [ ! -e ./sh0pcx/$tgt ]; then

     mkdir sh0pcx/$tgt

   fi

#  if [ ! -e ./sh1pcx/$tgt ]; then

#   mkdir sh1pcx/$tgt

#  fi

   if [ ! -e ./sh2pcx/$tgt ]; then

     mkdir sh2pcx/$tgt

   fi

   if [ ! -e ./sh3pcx/$tgt ]; then

     mkdir sh3pcx/$tgt

   fi   

 done

fi

 

# 8-segments for multi-palette for motion video

# if ls ./*.bmp 1> /dev/null 2>&1 ; then

# for i in $( ls $criteria); do

#    src=$i

#    tgt=$(basename $i .bmp)

#    $MAGICK $src -crop 320x25+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//0.pcx

#    $MAGICK $src -crop 320x25+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//1.pcx

#    $MAGICK $src -crop 320x25+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//2.pcx

#    $MAGICK $src -crop 320x25+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//3.pcx

#    $MAGICK $src -crop 320x25+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//4.pcx

#    $MAGICK $src -crop 320x25+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//5.pcx

#    $MAGICK $src -crop 320x25+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//6.pcx

#    $MAGICK $src -crop 320x25+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh1pcx//$tgt//7.pcx

#  done

# fi

 

# use the same segments currently used in A2B

 

# 1-segment for single palette SHR

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   $MAGICK $src -dither FloydSteinberg -colors 16 -define format:PCX sh0pcx//$tgt//0.pcx

 done

fi

 

# 16-segments for multi-palette

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   $MAGICK $src -crop 320x13+0+187 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//0.pcx

   $MAGICK $src -crop 320x12+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//1.pcx

   $MAGICK $src -crop 320x13+0+162 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//2.pcx

   $MAGICK $src -crop 320x12+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//3.pcx

   $MAGICK $src -crop 320x13+0+137 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//4.pcx

   $MAGICK $src -crop 320x12+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//5.pcx

   $MAGICK $src -crop 320x13+0+112 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//6.pcx

   $MAGICK $src -crop 320x12+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//7.pcx

   $MAGICK $src -crop 320x13+0+87 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//8.pcx

   $MAGICK $src -crop 320x12+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//9.pcx

   $MAGICK $src -crop 320x13+0+62 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//10.pcx

   $MAGICK $src -crop 320x12+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//11.pcx

   $MAGICK $src -crop 320x13+0+37 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//12.pcx

   $MAGICK $src -crop 320x12+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//13.pcx

   $MAGICK $src -crop 320x13+0+12 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//14.pcx

   $MAGICK $src -crop 320x12+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh2pcx//$tgt//15.pcx

 done

fi

 

# 200-segments for brooks

if ls ./*.bmp 1> /dev/null 2>&1 ; then

for i in $( ls $criteria); do

   src=$i

   tgt=$(basename $i .bmp)

   $MAGICK $src -crop 320x1+0+199 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//0.pcx

   $MAGICK $src -crop 320x1+0+198 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//1.pcx

   $MAGICK $src -crop 320x1+0+197 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//2.pcx

   $MAGICK $src -crop 320x1+0+196 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//3.pcx

   $MAGICK $src -crop 320x1+0+195 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//4.pcx

   $MAGICK $src -crop 320x1+0+194 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//5.pcx

   $MAGICK $src -crop 320x1+0+193 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//6.pcx

   $MAGICK $src -crop 320x1+0+192 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//7.pcx

   $MAGICK $src -crop 320x1+0+191 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//8.pcx

   $MAGICK $src -crop 320x1+0+190 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//9.pcx

   $MAGICK $src -crop 320x1+0+189 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//10.pcx

   $MAGICK $src -crop 320x1+0+188 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//11.pcx

   $MAGICK $src -crop 320x1+0+187 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//12.pcx

   $MAGICK $src -crop 320x1+0+186 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//13.pcx

   $MAGICK $src -crop 320x1+0+185 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//14.pcx

   $MAGICK $src -crop 320x1+0+184 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//15.pcx

   $MAGICK $src -crop 320x1+0+183 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//16.pcx

   $MAGICK $src -crop 320x1+0+182 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//17.pcx

   $MAGICK $src -crop 320x1+0+181 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//18.pcx

   $MAGICK $src -crop 320x1+0+180 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//19.pcx

   $MAGICK $src -crop 320x1+0+179 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//20.pcx

   $MAGICK $src -crop 320x1+0+178 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//21.pcx

   $MAGICK $src -crop 320x1+0+177 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//22.pcx

   $MAGICK $src -crop 320x1+0+176 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//23.pcx

   $MAGICK $src -crop 320x1+0+175 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//24.pcx

   $MAGICK $src -crop 320x1+0+174 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//25.pcx

   $MAGICK $src -crop 320x1+0+173 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//26.pcx

   $MAGICK $src -crop 320x1+0+172 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//27.pcx

   $MAGICK $src -crop 320x1+0+171 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//28.pcx

   $MAGICK $src -crop 320x1+0+170 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//29.pcx

   $MAGICK $src -crop 320x1+0+169 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//30.pcx

   $MAGICK $src -crop 320x1+0+168 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//31.pcx

   $MAGICK $src -crop 320x1+0+167 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//32.pcx

   $MAGICK $src -crop 320x1+0+166 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//33.pcx

   $MAGICK $src -crop 320x1+0+165 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//34.pcx

   $MAGICK $src -crop 320x1+0+164 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//35.pcx

   $MAGICK $src -crop 320x1+0+163 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//36.pcx

   $MAGICK $src -crop 320x1+0+162 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//37.pcx

   $MAGICK $src -crop 320x1+0+161 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//38.pcx

   $MAGICK $src -crop 320x1+0+160 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//39.pcx

   $MAGICK $src -crop 320x1+0+159 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//40.pcx

   $MAGICK $src -crop 320x1+0+158 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//41.pcx

   $MAGICK $src -crop 320x1+0+157 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//42.pcx

   $MAGICK $src -crop 320x1+0+156 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//43.pcx

   $MAGICK $src -crop 320x1+0+155 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//44.pcx

   $MAGICK $src -crop 320x1+0+154 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//45.pcx

   $MAGICK $src -crop 320x1+0+153 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//46.pcx

   $MAGICK $src -crop 320x1+0+152 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//47.pcx

   $MAGICK $src -crop 320x1+0+151 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//48.pcx

   $MAGICK $src -crop 320x1+0+150 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//49.pcx

   $MAGICK $src -crop 320x1+0+149 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//50.pcx

   $MAGICK $src -crop 320x1+0+148 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//51.pcx

   $MAGICK $src -crop 320x1+0+147 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//52.pcx

   $MAGICK $src -crop 320x1+0+146 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//53.pcx

   $MAGICK $src -crop 320x1+0+145 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//54.pcx

   $MAGICK $src -crop 320x1+0+144 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//55.pcx

   $MAGICK $src -crop 320x1+0+143 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//56.pcx

   $MAGICK $src -crop 320x1+0+142 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//57.pcx

   $MAGICK $src -crop 320x1+0+141 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//58.pcx

   $MAGICK $src -crop 320x1+0+140 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//59.pcx

   $MAGICK $src -crop 320x1+0+139 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//60.pcx

   $MAGICK $src -crop 320x1+0+138 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//61.pcx

   $MAGICK $src -crop 320x1+0+137 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//62.pcx

   $MAGICK $src -crop 320x1+0+136 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//63.pcx

   $MAGICK $src -crop 320x1+0+135 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//64.pcx

   $MAGICK $src -crop 320x1+0+134 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//65.pcx

   $MAGICK $src -crop 320x1+0+133 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//66.pcx

   $MAGICK $src -crop 320x1+0+132 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//67.pcx

   $MAGICK $src -crop 320x1+0+131 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//68.pcx

   $MAGICK $src -crop 320x1+0+130 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//69.pcx

   $MAGICK $src -crop 320x1+0+129 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//70.pcx

   $MAGICK $src -crop 320x1+0+128 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//71.pcx

   $MAGICK $src -crop 320x1+0+127 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//72.pcx

   $MAGICK $src -crop 320x1+0+126 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//73.pcx

   $MAGICK $src -crop 320x1+0+125 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//74.pcx

   $MAGICK $src -crop 320x1+0+124 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//75.pcx

   $MAGICK $src -crop 320x1+0+123 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//76.pcx

   $MAGICK $src -crop 320x1+0+122 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//77.pcx

   $MAGICK $src -crop 320x1+0+121 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//78.pcx

   $MAGICK $src -crop 320x1+0+120 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//79.pcx

   $MAGICK $src -crop 320x1+0+119 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//80.pcx

   $MAGICK $src -crop 320x1+0+118 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//81.pcx

   $MAGICK $src -crop 320x1+0+117 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//82.pcx

   $MAGICK $src -crop 320x1+0+116 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//83.pcx

   $MAGICK $src -crop 320x1+0+115 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//84.pcx

   $MAGICK $src -crop 320x1+0+114 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//85.pcx

   $MAGICK $src -crop 320x1+0+113 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//86.pcx

   $MAGICK $src -crop 320x1+0+112 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//87.pcx

   $MAGICK $src -crop 320x1+0+111 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//88.pcx

   $MAGICK $src -crop 320x1+0+110 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//89.pcx

   $MAGICK $src -crop 320x1+0+109 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//90.pcx

   $MAGICK $src -crop 320x1+0+108 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//91.pcx

   $MAGICK $src -crop 320x1+0+107 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//92.pcx

   $MAGICK $src -crop 320x1+0+106 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//93.pcx

   $MAGICK $src -crop 320x1+0+105 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//94.pcx

   $MAGICK $src -crop 320x1+0+104 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//95.pcx

   $MAGICK $src -crop 320x1+0+103 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//96.pcx

   $MAGICK $src -crop 320x1+0+102 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//97.pcx

   $MAGICK $src -crop 320x1+0+101 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//98.pcx

   $MAGICK $src -crop 320x1+0+100 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//99.pcx

   $MAGICK $src -crop 320x1+0+99 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//100.pcx

   $MAGICK $src -crop 320x1+0+98 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//101.pcx

   $MAGICK $src -crop 320x1+0+97 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//102.pcx

   $MAGICK $src -crop 320x1+0+96 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//103.pcx

   $MAGICK $src -crop 320x1+0+95 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//104.pcx

   $MAGICK $src -crop 320x1+0+94 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//105.pcx

   $MAGICK $src -crop 320x1+0+93 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//106.pcx

   $MAGICK $src -crop 320x1+0+92 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//107.pcx

   $MAGICK $src -crop 320x1+0+91 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//108.pcx

   $MAGICK $src -crop 320x1+0+90 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//109.pcx

   $MAGICK $src -crop 320x1+0+89 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//110.pcx

   $MAGICK $src -crop 320x1+0+88 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//111.pcx

   $MAGICK $src -crop 320x1+0+87 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//112.pcx

   $MAGICK $src -crop 320x1+0+86 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//113.pcx

   $MAGICK $src -crop 320x1+0+85 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//114.pcx

   $MAGICK $src -crop 320x1+0+84 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//115.pcx

   $MAGICK $src -crop 320x1+0+83 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//116.pcx

   $MAGICK $src -crop 320x1+0+82 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//117.pcx

   $MAGICK $src -crop 320x1+0+81 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//118.pcx

   $MAGICK $src -crop 320x1+0+80 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//119.pcx

   $MAGICK $src -crop 320x1+0+79 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//120.pcx

   $MAGICK $src -crop 320x1+0+78 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//121.pcx

   $MAGICK $src -crop 320x1+0+77 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//122.pcx

   $MAGICK $src -crop 320x1+0+76 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//123.pcx

   $MAGICK $src -crop 320x1+0+75 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//124.pcx

   $MAGICK $src -crop 320x1+0+74 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//125.pcx

   $MAGICK $src -crop 320x1+0+73 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//126.pcx

   $MAGICK $src -crop 320x1+0+72 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//127.pcx

   $MAGICK $src -crop 320x1+0+71 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//128.pcx

   $MAGICK $src -crop 320x1+0+70 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//129.pcx

   $MAGICK $src -crop 320x1+0+69 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//130.pcx

   $MAGICK $src -crop 320x1+0+68 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//131.pcx

   $MAGICK $src -crop 320x1+0+67 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//132.pcx

   $MAGICK $src -crop 320x1+0+66 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//133.pcx

   $MAGICK $src -crop 320x1+0+65 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//134.pcx

   $MAGICK $src -crop 320x1+0+64 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//135.pcx

   $MAGICK $src -crop 320x1+0+63 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//136.pcx

   $MAGICK $src -crop 320x1+0+62 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//137.pcx

   $MAGICK $src -crop 320x1+0+61 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//138.pcx

   $MAGICK $src -crop 320x1+0+60 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//139.pcx

   $MAGICK $src -crop 320x1+0+59 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//140.pcx

   $MAGICK $src -crop 320x1+0+58 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//141.pcx

   $MAGICK $src -crop 320x1+0+57 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//142.pcx

   $MAGICK $src -crop 320x1+0+56 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//143.pcx

   $MAGICK $src -crop 320x1+0+55 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//144.pcx

   $MAGICK $src -crop 320x1+0+54 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//145.pcx

   $MAGICK $src -crop 320x1+0+53 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//146.pcx

   $MAGICK $src -crop 320x1+0+52 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//147.pcx

   $MAGICK $src -crop 320x1+0+51 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//148.pcx

   $MAGICK $src -crop 320x1+0+50 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//149.pcx

   $MAGICK $src -crop 320x1+0+49 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//150.pcx

   $MAGICK $src -crop 320x1+0+48 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//151.pcx

   $MAGICK $src -crop 320x1+0+47 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//152.pcx

   $MAGICK $src -crop 320x1+0+46 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//153.pcx

   $MAGICK $src -crop 320x1+0+45 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//154.pcx

   $MAGICK $src -crop 320x1+0+44 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//155.pcx

   $MAGICK $src -crop 320x1+0+43 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//156.pcx

   $MAGICK $src -crop 320x1+0+42 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//157.pcx

   $MAGICK $src -crop 320x1+0+41 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//158.pcx

   $MAGICK $src -crop 320x1+0+40 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//159.pcx

   $MAGICK $src -crop 320x1+0+39 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//160.pcx

   $MAGICK $src -crop 320x1+0+38 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//161.pcx

   $MAGICK $src -crop 320x1+0+37 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//162.pcx

   $MAGICK $src -crop 320x1+0+36 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//163.pcx

   $MAGICK $src -crop 320x1+0+35 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//164.pcx

   $MAGICK $src -crop 320x1+0+34 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//165.pcx

   $MAGICK $src -crop 320x1+0+33 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//166.pcx

   $MAGICK $src -crop 320x1+0+32 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//167.pcx

   $MAGICK $src -crop 320x1+0+31 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//168.pcx

   $MAGICK $src -crop 320x1+0+30 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//169.pcx

   $MAGICK $src -crop 320x1+0+29 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//170.pcx

   $MAGICK $src -crop 320x1+0+28 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//171.pcx

   $MAGICK $src -crop 320x1+0+27 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//172.pcx

   $MAGICK $src -crop 320x1+0+26 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//173.pcx

   $MAGICK $src -crop 320x1+0+25 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//174.pcx

   $MAGICK $src -crop 320x1+0+24 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//175.pcx

   $MAGICK $src -crop 320x1+0+23 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//176.pcx

   $MAGICK $src -crop 320x1+0+22 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//177.pcx

   $MAGICK $src -crop 320x1+0+21 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//178.pcx

   $MAGICK $src -crop 320x1+0+20 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//179.pcx

   $MAGICK $src -crop 320x1+0+19 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//180.pcx

   $MAGICK $src -crop 320x1+0+18 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//181.pcx

   $MAGICK $src -crop 320x1+0+17 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//182.pcx

   $MAGICK $src -crop 320x1+0+16 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//183.pcx

   $MAGICK $src -crop 320x1+0+15 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//184.pcx

   $MAGICK $src -crop 320x1+0+14 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//185.pcx

   $MAGICK $src -crop 320x1+0+13 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//186.pcx

   $MAGICK $src -crop 320x1+0+12 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//187.pcx

   $MAGICK $src -crop 320x1+0+11 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//188.pcx

   $MAGICK $src -crop 320x1+0+10 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//189.pcx

   $MAGICK $src -crop 320x1+0+9 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//190.pcx

   $MAGICK $src -crop 320x1+0+8 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//191.pcx

   $MAGICK $src -crop 320x1+0+7 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//192.pcx

   $MAGICK $src -crop 320x1+0+6 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//193.pcx

   $MAGICK $src -crop 320x1+0+5 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//194.pcx

   $MAGICK $src -crop 320x1+0+4 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//195.pcx

   $MAGICK $src -crop 320x1+0+3 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//196.pcx

   $MAGICK $src -crop 320x1+0+2 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//197.pcx

   $MAGICK $src -crop 320x1+0+1 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//198.pcx

   $MAGICK $src -crop 320x1+0+0 -dither FloydSteinberg -colors 16 -define format:PCX sh3pcx//$tgt//199.pcx

 done

fi

 

# this is the end