Image Shredder The goal of Image Shredder is to enable Image Manipulation functionality not available any where else. Many of the functions available in Image Shredder are available elsewhere. They are included anyway for your convenience and because they were easy to implement. Over time, more functionality will be added that is unique to Image Shredder. Send all feature requests to patcoston@gmail.com. Notes: This program reads and writes PPM (Portable Pixel Maps). The reason PPM was chosen is because it is a simple file format to read and write. It has a simple header and stores each pixel as 3 bytes. Byte 1 is for Red Byte 2 is for Green Byte 3 is for Blue We refer to these bytes as RGB. Imageshredder allows you to act upon these bytes individually. Syntax: imageshredder [infile] [outfile] [option 1] [option 2] ... [option n] - infile - the name of the PPM file to read (required) - outfile - the name of the PPM file to write (required) - option - You can specify one or more options Example: - imageshredder before.ppm after.ppm mirror flip - imageshredder before.ppm after.ppm rndpercent 50 - imageshredder before.ppm after.ppm rndcol 20 rndrow 20 - imageshredder before.ppm after.ppm shift 0 0 5 mixrgb RR GB BG - imageshredder before.ppm after.ppm sort flip mirror rnd 20 shift -1 1 5 mixrgb RB GG BB Key: Letters RGB if shown are to be listed as letters substitute a value [N] optional value Options: - mixpix - randomly re-arranges n% pixels ex: rndpercent 50 - randomize 50% of the pixels ex: rndpercent 100 - randomize 500% of the pixels - mixrgb AB AB AB - re-arrange the RGB bytes ex: mixrgb RG GB BR - set Red to Green, Green to Blue and Blue to Red ex: mixrgb RR GG BG - Red and Green do not change, set Blue to Green ex: mixrgb RB GB BR - set Red to Blue, Green to Blue, Blue to Red note: You must specify what to set for R, G and B even if you are not changing 1 or 2 of them. - shift - shift the RGB bytes left or right 0 to 8 bits Effect: Posterize ex: shift 0 0 1 - shift Blue 1 bit right ex: shift 0 0 -1 - shift Blue 1 bit left ex: shift 1 0 -5 - shift Red 1 bit right, Blue 5 bits left ex: shift 3 -2 -4 - shift Red 3 bits right, Green 2 bits left, Blue 4 bits left note: bits 11110000 shifted left 2 would be 11000000. shifted 2 right would be 00111100 - sort RGB - sort pixels by combining RGB bytes into a single integer You can also specify X for bytes you don't want to sort by ex: sort RXX - sort by Red ex: sort XGB - sort by Green and Blue ex: sort RXB - sort by Red and Blue ex: sort RGB - sort by Red, Green, Blue note: if sorting by two or three colors, the bytes are combined into a single number which is used to sort by note: First letter is either R or X. Second letter is either G or X. Third letter is either G or X. - mirror - create a mirror image left to right - flip - invert the image upside down - negative RGB - invert the pixels You can also specify X for bytes you don't want to sort by ex: negative RXX - invert Red byte ex: negative RXB - invert Red and Blue byte ex: negative XGB - invert Green and Blue type ex: negative RGB - invert all 3 RGB bytes note: flips the bits in the RGB bytes. 11110000 becomes 00001111. - rndcol N - randomize the columns. n specifies how thick each column is ex: rndcol 1 - randomize columns of width 1 ex: rndcol 10 - randomize columns of width 10 ex: rndcol 100 - randomize columns of width 100 note: column width must evently divide into width of image or effect will not occur - rndrow N - randomize the rows. n specifies how thick each column is ex: rndrow 1 - randomize rows of width 1 ex: rndrow 10 - randomize rows of width 10 ex: rndrow 100 - randomize rows of width 100 note: row height must evently divide into height of image or effect will not occur - grey N - turn the image grey in several different ways 1 - average the RGB bytes together and set them all to the average 2 - logical OR the RGB bytes together and set them all to the result 3 - logical AND the RGB bytes together and set them all to the result 4 - logical XOR the RGB bytes together and set them all to the result ex: grey 1 - average RGB ex: grey 4 - XOR RGB note: When the RGB bytes all equal the same amount, you have a shade of grey. therefore there are 256 shades of grey from 0/0/0 to 255/255/255 - mathfun r g b N - add or subtract a value from each byte. N = 1 = Add value (value becomes 255 if exceeds 255) N = 2 = Subtract value (value becomes 0 if falls below 0) N = 3 = Multiply value (value becomes 255 if exceeds 255) N = 4 = Divide value N = 5 = Raise to the power (value becomes 255 if exceeds 255) N = 6 = Take the root of Effect: Brighten and Darken ex: addsub 20 20 20 - add 20 to the Red, Green and Blue bytes ex: addsub -20 -20 -20 - subtract 20 from the Red, Green and Blue bytes ex: addsub 50 0 -100 - add 50 to the Red byte, subtract 100 from the Blue byte note: if the total exceeds 255 it will be set to 255. if the total is less than 0, it will be set to 0. - mask B V N - logically combines B = R, G or B - specify which byte you want to Mask V = Value of Mask (0 to 255) N = 1 = OR Mask N = 2 = AND Mask N = 3 = XOR Mask - blend RGB - combine another image with this one in various ways filename - second PPM file. Does not have to be the same size as the input PPM file. Second PPM file constrained by first PPM file. x / y - column / row offset to overlap original image. Can be negative. effect - a number indicating the special effect av - average the bytes together or - OR the bytes together and - AND the bytes together xor - XOR the bytes together add - add the two bytes together. If exceeds 255, will be 255 mult - multiply the two bytes together. If exceeds 255, will be 255 div1 - divide byte from file1 into byte of file2 div2 - divide byte from file2 into byte of file1 sub1 - subtract byte from image1 from image2. If less than 0, will be 0. sub2 - subtract byte from image2 from image1. If less than 0, will be 0. abssub - subtract byte from image1 from image2 and take absolute value. RGB - Specify which bytes to act upon: R=Red G=Green B=Blue. Must specify in that order. Use X for Not, as in Not Red. ex: blend file2.ppm 0 0 av RXX - average the Red bytes together. No x,y offset ex: blend file2.ppm 20 20 or XGB - OR the Green and Blue bytes together. offset 20, 20 ex: blend file2.ppm 120 47 xor RXB - XOR the Green bytes together. offset 120, 47 note: parts of image2 that extend beyond the right edge and bottom of the original image will be cropped Meta-Options: The following Options modify certain options above. They specify which pixels the effect is to be used on. "rnd" specifies a random pattern while "evenodd" specifies a pattern effect. - rnd - prefixes certain options. Specifies to make the change randomly for a specified percentage of the picture. N - percentage of picture to perform change Modifies Options: mixrgb, shift, sort1, sort2, sort3, mirror, flip, negative, grey, mathfun, mask, image2 Does Not Modify Functions that are already Random: mixpix, rndcol, rndrow ex: rnd 50 negative RGB - negative effect on RGB bytes on 50% of the pixels randomly ex: rnd 80 mathfun 10 20 30 1 - add 10 to Red, 20 to Green and 30 to Blue on 80% of the pixels randomly ex; rnd 25 blend other.ppm xor XXB - xor Blue byte of image1 with image2 on 25% of the pixels randomly - evenodd - prefixes certain options. Specifies to do the effect on either the even or odd number of pixels. even/odd - even or odd - indicates which pixels, rows or columns to perform effect on pix/row/col - does the effect occur on the pixels, rows or columns thickness - Use 1 for pix. When specifying row or col, a thickness must be specified. Modifies Options: mixrgb, shift, sort1, sort2, sort3, mirror, flip, negative, grey, mathfun, mask, image2 Does Not Modify Functions that are already Random: mixpix, rndcol, rndrow ex: evenodd even pix mirror - mirror effect on even numbered pixels ex: evenodd odd row 1 flip - flip effect on odd rows 1 pixel thick ex: exenodd odd col 5 mask G 255 3 - xor mask effect on Green byte on odd numbered columns 5 pixels thick