+ Reply to Thread
Results 1 to 5 of 5

Thread: Random Scripts, command Line tricks for those who like *nix type shells

  1. #1
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    54

    Lightbulb Random Scripts, command Line tricks for those who like *nix type shells

    I use Midnight Commander under Win32, and I run GAWK (GNU awk) to make webp files from jpegs. I know that I have hard coded my B: ramdrive directory but this is just a hack to to convert jpegs via PBMtools to have an unsharp mask applied and change gamma to lighten the image ( via the mask ).

    Actually, convert.exe from Imagemagick can do shorter work than this, but it consumes too many CPU cycles on my machine. I did this so it would run more predictably while I browse internet.

    ### Obviously I am escaping some literals, Octal value 174 is ascii | and octal value 076 is >
    ### Pipe jpeg list to input, and make the greymap that we will use on all the PNMs in the PNMconvol utility
    dir/b *.jpg | gawk "BEGIN{printf\"@pamgauss 19 19 -sigma=.2 -tupletype=GRAYSCALE \174 pamtopnm \076 b:\\000\\01gauss.pgm\n\"}
    ### Increment a counter, and if Modulus of 16 is zero then print a line that halts the batch file for twenty seconds, then assign the filename minus the extentsion to A1
    {{ idx++; if (!(idx%%16)) printf\"@powershell start-sleep 20\n\"; A1=substr($1,1,(length($1)-4));
    ###Print a Label for each block operation, useful if you interrupt like "goto :skip3000. Convert the jpeg to pnm, Blur the image to use as a mask and fudge Gamma 1.1
    ###Pammasksharpen removes this Map from the original, then Pipe it to the PNG writer pnmtopng. Cwebp is Google's utility.
    printf \":skip%%04d\n\@del b:\\000\\010101.ppm\n@jpegtopnm %%s.jpg \076 b:\\000\\010101.ppm\n@pnmconvol -nooffset b:\\000\\01gauss.pgm b:\\000\\010101.ppm \174 pnmgamma 1.1 \076 b:\\000\\100000.ppm\n@pammasksharpen b:\\000\\100000.ppm b:\\000\\010101.ppm \174 pnmtopng \076 b:\\000\\00000sharp.png\n@if not exist b:\\000\\00000sharp.png goto skip%%04d\n\",idx,A1,idx+1; printf\"@cwebp -af -q %%d b:\\000\\00000sharp.png -pass 4 -o b:\\000\\%%s.webp\n\",(idx%%4)+86,A1}}" > %D\0a.bat

    ^Yay the end of the gAWK script. Sometimes instead of redirect to file I pipe it thru SED first, if I want to chage directory locations, or I do a notepad search and replace.
    Yes I am old but since I grew up with computers at the same time Pugh was making skiplists, you can't teach an old dog new tricks. If I get anything humongous like this again I will re-post here. Comments and derision welcome.

  2. #2
    Member m^2's Avatar
    Join Date
    Sep 2008
    Location
    Kce, PL
    Posts
    1,037
    Do you know glicbawls?
    Somehow it just came to my mind...

  3. #3
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    54
    Well AWK isn't made to be readable, just succinct. At least I don't use this language.

  4. #4
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    54

    Splitting YUV image

    OK now I need help, Im am trying to do this using Imagemagick 6.7.4-9 static DLL build and I am trying to do the effect mentioned here "Split Barn YUV planes" and I can't get the -clone operator to work ( reminds me of ML and Lisp the horror ! )

    I did this convert barn.png -colorspace YUV -sampling-factor 4:2:2 -separate -write mpr:Uval +delete mpr:Uval -negate -write mpr:Uneg +delete -fill black -colorize 100% -write mpr:Ublk +delete mpr:Uneg mpr:Uval mpr:Ublk frame%02d.png

    Any suggestions welcome.
    Attached Files Attached Files

  5. #5
    Member Karhunen's Avatar
    Join Date
    Dec 2011
    Location
    USA
    Posts
    54
    I am attaching a small C program that was cut out of the source code CRC-32 version 2.0.0 by Craig Bruce, 2006-04-29. I used the Fabrice Belard TinyCC compiler to make my 2k Windoze executable. I am a Dave Dunfield fan an loved the MICRO-C compiler and can still run it under DosBox, but TinyCC makes Win PE exes. I make batchfiles like the following with AWK:
    @if exist 113.webp @sizeof 113.webp 113.jpg
    @if errorlevel 1 del 113.webp
    et cetera. I personally can deal with the artifacts WEBP makes, and this is just to check for "pathologic" files that are bigger than the original jpeg.
    Attached Files Attached Files

+ Reply to Thread

Similar Threads

  1. command-line calculator for Windows?
    By Alexander Ratushnyak in forum Off-Topic
    Replies: 5
    Last Post: 30th January 2012, 01:40
  2. Replies: 3
    Last Post: 22nd November 2011, 23:24
  3. UCLC (Ultimate Command Line Compressors) Benchmarks
    By osmanturan in forum Data Compression
    Replies: 1
    Last Post: 26th February 2009, 04:47
  4. a small plea for the command line compression developers
    By SvenBent in forum Data Compression
    Replies: 2
    Last Post: 14th June 2008, 03:51
  5. DARK - a new BWT-based command-line archiver
    By encode in forum Forum Archive
    Replies: 138
    Last Post: 23rd September 2006, 22:42

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts