snibgo's ImageMagick pages

Lithographic effects

IM can make images in the style of simple lithographs, halftone, silk-screen and similar processes.

From a photograph, we can make graphic images. This is a process of simplification.

Lithography (literally "writing with stones") is a printing process that is capable of very subtle effects. Lithographic emulsions, or simply "lith", are used (or were used, back in my day) in the printing industry. If exposed and processed in a certain way it gives almost infinite contrast, so the result is black and white, with no grays. Gray tones are simulated by different proportions of black (the ink) and white (the uninked paper).

(I think lith was always monochrome. For colour work, CMYK separations were made for processing, then combined at the printing stage.)

Sample inputs

We demonstrate with a photograph and a grayscale wedge.

set SRC=li_src.jpg
set SRC_BW=li_src_bw.png

if not exist %SRC% copy zp_ssd.jpg %SRC%

%IM%convert ^
  %SRC% ^
  -colorspace Gray ^
  +depth ^
  %SRC_BW%

set sioJPEG_EXT=.png
li_src.jpg li_src_bw.pngjpg
set SRC_W=li_wedge_src.png

%IM%convert ^
  -size 80x40 ^
  xc:Black xc:gray(25%%) xc:gray(50%%) xc:gray(75%%) xc:White ^
  +append ^
  -size 40x400 ^
  ( gradient: -rotate 90 ) ^
  -append ^
  -rotate -90 ^
  %SRC_W%
li_wedge_src.png

Thresholding

Lith (aka "litho" or "line") film is very high contrast. The simple equivalent in IM is "-threshold". Here is a sampler, varying the threshold between 10% and 90%.

(Lith films are often orthochromatic, which meant they are relatively insensitive to red light. I am ignoring this aspect.)

call %PICTBAT%thresh9 %SRC_BW%
li_src_th9.png

The most pleasing image is perhaps "-threshold 50%". We have lost most detail. Many areas of the image are either black or white. For example, the woman's legs are clear in only two frames.

To increase local contrast, we can extrapolate from heavy blur:

call %PICTBAT%exHvyBlr %SRC_BW% 4 500
li_src_ehb.png

Make a threshold sampler:

call %PICTBAT%thresh9 %ehbOUTFILE%
li_src_ehb_th9.png

The woman's legs are now clear in 7 of the 9 images, a big improvement on the previous version.

Remapping

An alternative lith effect is by remapping to black and white, with or without dithering. With dithering, the step wedge shows we can get accidental patterns forming; this is rarely a problem in ordinary photographs. With no dithering, the result is very similar to "-threshold 50%".

%IM%convert xc:black xc: +append li_bw.png

%IM%convert ^
  %SRC_BW% ^
  -remap li_bw.png ^
  li_remap_dith.png

%IM%convert ^
  %SRC_W% ^
  -remap li_bw.png ^
  li_remap_dith_w.png

%IM%convert ^
  %SRC_BW% ^
  +dither -remap li_bw.png ^
  li_remap_nodith.png

%IM%convert ^
  %SRC_W% ^
  +dither -remap li_bw.png ^
  li_remap_nodith_w.png
li_remap_dith.png li_remap_dith_w.png li_remap_nodith.png li_remap_nodith_w.png

Aside: by default, dithering is turned on. To turn it off, use "+dither". Yeah, this syntax is counter-intuitive.

Remapping finds the closest colour from the map. To achieve a threshold-like variation, we can either change the image's intensity so the required level becomes 50%, or change the map and then auto-level. For example, to achieve a result similar to "-threshold 60%":

%IM%convert ^
  %SRC_BW% ^
  -modulate 84,100,100 ^
  +dither -remap li_bw.png ^
  li_remap_nodith2.png

%IM%convert ^
  xc:gray59 xc:gray61 +append -write mpr:MAP +delete ^
  %SRC_BW% ^
  +dither -remap mpr:MAP ^
  -auto-level ^
  li_remap_nodith3.png
li_remap_nodith2.png li_remap_nodith3.png

A different effect is to turn x% of the pixels black, and the rest white. (Beware: this doesn't work with 256c grayscale images.)

%IM%convert ^
  %SRC_BW% ^
  -contrast-stretch 50x50%% ^
  li_turnc1.png
li_turnc1.png

Halftoning

Halftoning is a method of simulating grayscale tone by using black and white only. When viewed from a distance, the human eye can't resolve the separate black and white areas, so we perceive shades of gray. Even when viewed closely enough to set the separate black and white, the brain mixes the two and interprets the image correctly, as if it contained gray.

The same principle applies to colours.

See also Wikipedia: Halftone.

The script lithScreen.bat applies a lith screen to a source image, making an output with black and white only. The screen should usually be a simple small grayscale image, which will be tiled the same size as the image. For each pixel, for each of the three color channels, it sets the pixel value to 100% if the source is greater than screen pixel, otherwise it sets the pixel value to zero.

We can make the lith screen by appending pixels, or with the script knl2img.bat (see Convolve: knl2img), or any other method.

In the examples, we show the lith screen (often too small to be visible), the lith screen enlarged, the result for the wedge image, and the result for the photograph.

Code Lith screen Wedge Photo
call %PICTBAT%knl2img ^
  "1x1:0.5" li_p1.png

call %PICTBAT%blockPix li_p1.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_p1.png li_hp1_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_p1.png li_hp1.png
li_p1.png li_p1_bp.png li_hp1_w.png li_hp1.png
call %PICTBAT%knl2img ^
  "1x6:0,1,3,5,4,2" li_s1.png . -auto-level

call %PICTBAT%knl2img ^
  "1x6:0,1,2,3,4,5" li_s1.png . -auto-level

call %PICTBAT%blockPix li_s1.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_s1.png li_h1_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_s1.png li_h1.png
li_s1.png li_s1_bp.png li_h1_w.png li_h1.png
%IMDEV%convert ^
  li_s1.png ^
  ( +clone -rotate 90 -evaluate divide 6 ) ^
  -scale "6x6^!" ^
  -define compose:clamp=off ^
  -compose Plus -composite ^
  -auto-level ^
  li_s2.png

call %PICTBAT%blockPix li_s2.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_s2.png li_h2_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_s2.png li_h2.png
li_s2.png li_s2_bp.png li_h2_w.png li_h2.png
1  9  15 20 7  3
5  18 27 32 24 12
22 29 35 34 26 17
14 25 33 36 31 21
11 19 30 28 16 6
4  8  13 23 10 2
6  7  8  24 25 26
5  0  1  23 18 19
4  3  2  22 21 20
33 34 35 15 16 17
32 27 28 14 9  10
31 30 29 13 12 11

The next examples use a 6x6 square that is tiled for the lith screen. This responds to 36 levels of gray. A larger number would be more responsive, but also more obtrusive.

Code Lith screen Wedge Photo

Spiral out from centre.

set sNUM=^
20, 21, 22, 23, 24,25,^
19,  6,  7,  8,  9,26,^
18,  5,  0,  1, 10,27,^
17,  4,  3,  2, 11,28,^
16, 15, 14, 13, 12,29,^
35, 34, 33, 32, 31,30

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_sp.png . -auto-level

call %PICTBAT%blockPix li_sp.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_sp.png li_spi_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_sp.png li_spi.png
li_sp.png li_sp_bp.png li_spi_w.png li_spi.png

A bricks pattern.

set sNUM=^
27, 31, 35, 15, 19, 23,^
26, 30, 34, 13, 17, 22,^
6,  7,  8,  9,  10, 11,^
14, 18, 21, 25, 29, 33,^
12, 16, 20, 24, 28, 32,^
0,  1,  2,  3,  4,  5

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_br.png . -auto-level

call %PICTBAT%blockPix li_br.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_br.png li_bri_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_br.png li_bri.png
li_br.png li_br_bp.png li_bri_w.png li_bri.png

We can capture more detail by breaking the 36x36 lith screen into smaller squares.

Code Lith screen Wedge Photo

Four squares of 3x3.

At increasing lightness, we fill each 3x3 before starting the next.

set sNUM=^
6,  7,  8,  24, 25, 26,^
5,  0,  1,  23, 18, 19,^
4,  3,  2,  22, 21, 20,^
33, 34, 35, 15, 16, 17,^
32, 27, 28, 14, 9,  10,^
31, 30, 29, 13, 12, 11

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_n1.png . -auto-level

call %PICTBAT%blockPix li_n1.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_n1.png li_n1i_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_n1.png li_n1i.png
li_n1.png li_n1_bp.png li_n1i_w.png li_n1i.png

Four squares of 3x3.

Alternate increases to opposite squares. When they are filled, do the other two.

set sNUM=^
12, 14, 16, 30, 32, 34,^
10, 0,  2,  28, 18, 20,^
8,  6,  4,  26, 24, 22,^
31, 33, 35, 13, 15, 17,^
29, 19, 21, 11, 1,  3,^
27, 25, 23, 9,  7,  5

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_n2.png . -auto-level

call %PICTBAT%blockPix li_n2.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_n2.png li_n2i_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_n2.png li_n2i.png
li_n2.png li_n2_bp.png li_n2i_w.png li_n2i.png

Four squares of 3x3.

Alternate increases to all four squares.

set sNUM=^
24, 28, 32, 26, 30, 34,^
20, 0,  4,  22, 2,  6,^
16, 12, 8,  18, 14, 10,^
27, 31, 35, 25, 29, 33,^
23, 3,  7,  21, 1,  5,^
19, 15, 11, 17, 13, 9

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_n3.png . -auto-level

call %PICTBAT%blockPix li_n3.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_n3.png li_n3i_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_n3.png li_n3i.png
li_n3.png li_n3_bp.png li_n3i_w.png li_n3i.png

Nine squares of 2x2.

rem 0 7 3
rem 4 1 6
rem 2 5 8

set sNUM=^
0,  18, 7,  25, 3,  21, ^
30, 9,  27, 16, 34, 12, ^
4,  22, 1,  19, 6,  24, ^
33, 13, 31, 10, 28, 15, ^
2,  20, 5,  23, 8,  26, ^
35, 11, 29, 14, 32, 17

call %PICTBAT%knl2img ^
  "6x6:%sNUM%" li_n4.png . -auto-level

call %PICTBAT%blockPix li_n4.png

call %PICTBAT%lithScreen ^
  %SRC_W% li_n4.png li_n4i_w.png

call %PICTBAT%lithScreen ^
  %SRC_BW% li_n4.png li_n4i.png
li_n4.png li_n4_bp.png li_n4i_w.png li_n4i.png

Also: 36x1 gradient, randomised (shuffled). Process module: for every pixel, swap it with one of the pixels in the image, chosen evenly amongst all the pixels (including itself).

Distorted screens

We can distort the lith screen before applying it.

This distorts the screen, not the image. However, an optical illusion may give the impression that the image has also distorted.

For screen rotation, we use code like this:

%IM%convert ^
  li_s1.png ^
  -set option:distort:viewport "300x200+0+0" ^
  -virtual-pixel tile ^
  -distort SRT 1,15 ^
  -auto-level ^
  li_rot.png
li_rot.png

The viewport size will come from the source image. The rotation angle could be zero, but we still need the "-distort SRT" as this gives the expansion of the lith screen to the viewport. Even at zero rotation, the distort may mess up the values, so we always -auto-level.For ths operation, -filter gaussian is sometimes used. But that always messes values, in a way that -auto-level can't fix.

An alternative is to make a big enough image, draw with the lith screen as a tile, and rotate the result. Making the image "big enough" is awkward. We composite a clone over a 90° rotated copy to get a square the maximum width or height, and resize up by a factor of sqrt(2). This is big enough to cope with any angle of rotation.

%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    -gravity center -border 20x20 ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -wave 10x100 ^
  ) ^
  -compose MinusSrc -composite ^
+write x.png ^
  -fill White +opaque Black ^
  li_ds1.png
li_ds1.png
%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    ( +clone -rotate 90 ) ^
    -gravity center -compose Over -layers merge ^
    -scale 150%% ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -rotate 15 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  li_ds2.png

The +clone -rotate 90 etc ensures we can cope with any angle.

li_ds2.png
%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    ( +clone -rotate 90 ) ^
    -gravity center -compose Over -layers merge ^
    -scale 142%% ^
    -tile li_n4.png -draw "color 0,0 reset" ^
    -rotate 15 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  li_ds3.png
li_ds3.png
call %PICTBAT%lithScreen ^
  %SRC_BW% li_s1.png li_ds2.png 15
li_ds2.png
call %PICTBAT%lithScreen ^
  %SRC_BW% li_n4.png li_ds3.png 15
li_ds3.png

Linear colorspace?

Antialiasing

When the lith screen contains curves, aliasing causes a "jump" effect, that is seen here as a vertical artifact. For example, we have vertical light streaks on the dark shirt where the screen is horizontal.

%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    -gravity center -border 20x20 ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -wave 10x100 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  li_ds1_2.png
li_ds1_2.png

To reduce this, we can supersample the image and screen before subtraction, and subsample afterwards. However, this violates the rule that we should have black and white only.

%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    -gravity center -border 20x20 ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -wave 10x100 ^
  ) ^
  -resize 400%% ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  -resize 25%% ^
  li_ds1_3.png
li_ds1_3.png

An alternative is to propate the quantization error. We can do this very easily, by remapping the image to the colours of the lith screen, with dithering.

%IM%convert ^
  %SRC_BW% ^
  -remap li_s1.png ^
  ( +clone ^
    -gravity center -border 20x20 ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -wave 10x100 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  li_ds1_3md.png
li_ds1_3md.png

But the result still has vertical artifacts. Instead of remapping, we can add some noise. The lith screen has intervals of 0.2. We add uniformly-distributed noise in the range -0.2 to +0.2. In an image area with constant tone, about half the pixels will be unchanged by the noise; the others will either be lightened to the next level up or darkened to the next level down.

%IM%convert ^
  %SRC_BW% ^
  ( +clone ^
    +noise Random ^
  ) ^
  -compose Mathematics ^
    -define compose:args=0,0.4,1,-0.2 ^
  -composite ^
+write x.png ^
  ( +clone ^
    -gravity center -border 20x20 ^
    -tile li_s1.png -draw "color 0,0 reset" ^
    -wave 10x100 ^
  ) ^
  -compose MinusSrc -composite ^
  -fill White +opaque Black ^
  li_ds1_3nr.png
li_ds1_3nr.png

Halftoning in colour

The script lithScreenRGB.bat separates the RGB channels, calls lithScreen.bat for each, and combines the results.

call %PICTBAT%lithScreenRGB ^
  %SRC% li_s1.png li_hc1.png
li_hc1.png

At each pixel, each channel is either zero or 100%, so each pixel is one of: black, red, green, blue, cyan, magenta, yellow or white. In dark areas of the source, KRGB predominate. In light areas we have mostly CMYW.

We can set the lith screen angle to any desired value for each channel.

For CMY images, we can use the same script.

%IM%convert ^
  %SRC% ^
  -colorspace CMY ^
  -set colorspace sRGB ^
  li_cmy.miff

call %PICTBAT%lithScreenRGB ^
  li_cmy.miff li_s1.png li_cmy_h.miff

%IM%convert ^
  li_cmy_h.miff ^
  -set colorspace CMY ^
  -colorspace sRGB ^
  li_cmy_h.png
li_cmy_h.png

This gives essentially the same result, as we would hope. However, compare says they are very different:

%IM%compare -metric RMSE li_cmy_h.png li_hc1.png NULL: 
57081.6 (0.871009)

An RMSE score of 87% is about as different as they could be. This is because, in each channel, the light and dark bands have swapped positions.

A CMYK image has four channels, so we have a separate script lithScreenCMYK.bat for that.

%IM%convert ^
  %SRC% ^
  -colorspace CMYK ^
  li_cmyk.miff

call %PICTBAT%lithScreenCMYK ^
  li_cmyk.miff li_s1.png li_cmyk_h.miff

%IM%convert ^
  li_cmyk_h.miff ^
  -set colorspace CMYK ^
  -colorspace sRGB ^
  li_cmyk_h.png
li_cmyk_h.png

A different effect:

%IM%convert ^
  %SRC% ^
  -set option:distort:viewport "%%wx%%h+0+0" ^
  -colorspace CMYK -separate ^
  null: ^
  ( -size 2x2 xc: ^
    ( +clone -negate ) +append ^
    ( +clone -negate ) -append ^
  ) ^
  -virtual-pixel tile -filter gaussian ^
  ( +clone -distort SRT 2,60 ) +swap ^
  ( +clone -distort SRT 2,30 ) +swap ^
  ( +clone -distort SRT 2,45 ) +swap ^
  ( +clone -distort SRT 2,0  -blur 0x0.7 ) +swap +delete ^
  -compose Overlay -layers composite ^
  -set colorspace CMYK -combine ^
  -colorspace RGB ^
  li_h0.png
li_h0.png

These multi-channel scripts have two converts, plus one convert per chanel, with intermediate files. For production use, they would be conflated into a single convert with no intermediate files.

Scripts

thresh9.bat

rem From image %1, makes 9-panel with varying threshold.
rem %2 is first number.
rem %3 is increment.

@if "%1"=="" findstr /B "rem @rem" %~f0 & exit /B 1

@setlocal enabledelayedexpansion

@call echoOffSave

@call %PICTBAT%setInOut %1 th9


@set BASE=%2
@if "%BASE%"=="" set BASE=10

@set DIFF=%3
@if "%DIFF%"=="" set DIFF=10

@set /A f0=%BASE%
@set /A f1=%BASE%+%DIFF%
@set /A f2=%BASE%+(%DIFF%*2)
@set /A f3=%BASE%+(%DIFF%*3)
@set /A f4=%BASE%+(%DIFF%*4)
@set /A f5=%BASE%+(%DIFF%*5)
@set /A f6=%BASE%+(%DIFF%*6)
@set /A f7=%BASE%+(%DIFF%*7)
@set /A f8=%BASE%+(%DIFF%*8)

@set OPTIONS=+dither

"%IM%convert" %INFILE% -resize "300x300^>" ^
  +dither ^
  ( -clone 0 ^
    ( -clone 0 %OPTIONS% -threshold %f0%%% -gravity center label:"-threshold %f0%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f1%%% -gravity center label:"-threshold %f1%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f2%%% -gravity center label:"-threshold %f2%%%" -append ) ^
    -delete 0 ^
    +append ^
  ) ^
  ( -clone 0 ^
    ( -clone 0 %OPTIONS% -threshold %f3%%% -gravity center label:"-threshold %f3%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f4%%% -gravity center label:"-threshold %f4%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f5%%% -gravity center label:"-threshold %f5%%%" -append ) ^
    -delete 0 ^
    +append ^
  ) ^
  ( -clone 0 ^
    ( -clone 0 %OPTIONS% -threshold %f6%%% -gravity center label:"-threshold %f6%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f7%%% -gravity center label:"-threshold %f7%%%" -append ) ^
    ( -clone 0 %OPTIONS% -threshold %f8%%% -gravity center label:"-threshold %f8%%%" -append ) ^
    -delete 0 ^
    +append ^
  ) ^
  -delete 0 ^
  -append ^
  %OUTFILE%

call echoRestore

@endlocal

lithScreen.bat

rem From image %1
rem and lith screen %2,
rem make output %3.
rem %4 is screen rotation angle, degrees clockwise.

@if "%2"=="" findstr /B "rem @rem" %~f0 & exit /B 1

@setlocal enabledelayedexpansion

rem @call echoOffSave

call %PICTBAT%setInOut %1 ls

set LITH_SCRN=%2

if not "%3"=="" if not "%3"=="." set OUTFILE=%3

set ANGLE=%4
if "%ANGLE%"=="." set ANGLE=
if "%ANGLE%"=="" set ANGLE=0

%IM%convert ^
  %INFILE% ^
  -set option:distort:viewport "%%wx%%h+0+0" ^
  ( %LITH_SCRN% ^
    -virtual-pixel tile -distort SRT "1,%ANGLE%" ^
    -auto-level ^
  ) ^
  -compose MinusSrc -composite ^
  -fill gray(100%%) +opaque gray(0) ^
  %OUTFILE%

rem %IM%convert li_s1.png -set option:distort:viewport "300x400+0+0"
rem   -virtual-pixel tile -filter gaussian -distort SRT 1,60 x.png

call echoRestore

@endlocal & set lsOUTFILE=%OUTFILE%

lithScreenRGB.bat

rem From RGB image %1
rem and lith screen %2,
rem make RGB halftone output %3.
rem %4 is optional quoted list of three numbers for the angles.

@if "%2"=="" findstr /B "rem @rem" %~f0 & exit /B 1

@setlocal enabledelayedexpansion

rem @call echoOffSave

call %PICTBAT%setInOut %1 lsrgb

set LITH_SCRN=%2

if not "%3"=="" if not "%3"=="." set OUTFILE=%3

set ANGLES=%~4
if "%ANGLES%"=="." set ANGLES=
if "%ANGLES%"=="" set ANGLES=0,120,-120

call parseCommaList "%ANGLES%" numAng Angs

%IM%convert ^
  %INFILE% ^
  -channel RGB ^
  -separate ^
  +adjoin ^
  lsrgb-%%d.miff

call %PICTBAT%lithScreen lsrgb-0.miff %LITH_SCRN% lsrgb_r.miff %Angs[0]%
if ERRORLEVEL 1 exit /B 1

call %PICTBAT%lithScreen lsrgb-1.miff %LITH_SCRN% lsrgb_g.miff %Angs[1]%
if ERRORLEVEL 1 exit /B 1

call %PICTBAT%lithScreen lsrgb-2.miff %LITH_SCRN% lsrgb_b.miff %Angs[2]%
if ERRORLEVEL 1 exit /B 1

%IM%convert ^
  lsrgb_r.miff lsrgb_g.miff lsrgb_b.miff ^
  -combine ^
  %OUTFILE%

call echoRestore

@endlocal & set lsrgbOUTFILE=%OUTFILE%

lithScreenCMYK.bat

rem From CMYK image %1
rem and lith screen %2,
rem make CMYK halftone output %3.
rem %4 is optional quoted list of four numbers for the angles.

@if "%2"=="" findstr /B "rem @rem" %~f0 & exit /B 1

@setlocal enabledelayedexpansion

rem @call echoOffSave

call %PICTBAT%setInOut %1 lsrgb

set LITH_SCRN=%2

if not "%3"=="" if not "%3"=="." set OUTFILE=%3

set ANGLES=%~4
if "%ANGLES%"=="." set ANGLES=
if "%ANGLES%"=="" set ANGLES=45,90,-45,0

call parseCommaList "%ANGLES%" numAng Angs

%IM%convert ^
  %INFILE% ^
  -channel CMYK ^
  -separate ^
  +adjoin ^
  lsrgb-%%d.miff

call %PICTBAT%lithScreen lsrgb-0.miff %LITH_SCRN% lsrgb_c.miff %Angs[0]%
if ERRORLEVEL 1 exit /B 1

call %PICTBAT%lithScreen lsrgb-1.miff %LITH_SCRN% lsrgb_m.miff %Angs[1]%
if ERRORLEVEL 1 exit /B 1

call %PICTBAT%lithScreen lsrgb-2.miff %LITH_SCRN% lsrgb_y.miff %Angs[2]%
if ERRORLEVEL 1 exit /B 1

call %PICTBAT%lithScreen lsrgb-3.miff %LITH_SCRN% lsrgb_k.miff %Angs[3]%
if ERRORLEVEL 1 exit /B 1

%IM%convert ^
  lsrgb_c.miff lsrgb_m.miff lsrgb_y.miff lsrgb_k.miff ^
  -set colorspace CMYK ^
  -combine ^
  %OUTFILE%

call echoRestore

@endlocal & set lsrgbOUTFILE=%OUTFILE%

parseCommaList.bat

rem Given %1 is a (quoted) comma- or space-separated list,
rem sets environment variables %2 to the number of values
rem and %3 (as an array) to the values.

set LIST=%~1

set pclNUM=%2
if "%pclNUM%"=="." set pclNUM=
if "%pclNUM%"=="" set pclNUM=argc

set pclVALS=%3
if "%pclVALS%"=="." set pclVALS=
if "%pclVALS%"=="" set pclVALS=argv

call :doParse %LIST%
set /A %pclNUM%=%pclN%

echo pclVALS=%pclVALS%

exit /B 0

:: --------------------------------------------
:: Subroutine

:doParse

set pclN=0
:loop
if "%1"=="" exit /B 0

echo 1=%1 2=%2 3=%3
set %pclVALS%[%pclN%]=%1
set /A pclN+=1
shift /1

goto loop

exit /B 0

All images on this page were created by the commands shown, using:

%IM%identify -version
Version: ImageMagick 6.9.5-3 Q16 x86 2016-07-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

To improve internet download speeds, some images may have been automatically converted (by ImageMagick, of course) from PNG to JPG.

Source file for this web page is lith.h1. To re-create this web page, run "procH1 whattrans".


This page, including the images, is my copyright. Anyone is permitted to use or adapt any of the code, scripts or images for any purpose, including commercial use.

Anyone is permitted to re-publish this page, but only for non-commercial use.

Anyone is permitted to link to this page, including for commercial use.


Page version v1.0 27-Oct-2016.

Page created 23-Nov-2016 17:13:32.

Copyright © 2016 Alan Gibson.