Sunday

imagemagic add text to image

rem different types of text annotations on existing images
rem cyan yellow orange gold 
rem -gravity SouthWest
rem draw text and annotate
rem C:\me\tools\magic\convert.exe  -fill cyan -pointsize 120 -gravity center -draw "text 0,300 '%~1' "   %2  out%2
rem  C:\me\tools\magic\convert.exe %2  -undercolor white -pointsize 120 -gravity SouthWest -fill cyan  -annotate 0      %1 out%2

rem - klasnij horizontal append
rem C:\me\tools\magic\convert.exe %2  -background white -pointsize 120 label:%1  -gravity Center -append    out%2
rem C:\me\tools\magic\convert.exe %2 ( -size 600x -background red -fill black label:%1 -rotate 90 -trim +repage ) -gravity west -geometry +20+0 -composite out%2 
rem wow pashe vertical append 
rem C:\me\tools\magic\convert.exe %2 ( -size 1000x -background white -fill black label:%1 -rotate 90 -trim +repage ) -gravity east  +append out%2 

rem changing image size with horisontal append 
rem C:\me\tools\magic\convert.exe %2 ( -size 1500x -background white -fill black label:%1  -trim +repage ) -gravity east  +append out%2 

rem cool annotation with changing image size 
C:\me\tools\magic\convert.exe %2 ( -size 1500x -background white -fill black label:%1  -trim +repage ) -gravity center -append out%2

note that %~1 is command line argument without double quotes.

Wednesday

powershell compare two csv files and output differences

 I had to compare data returned from two APIs - one JSON another XML so

1. I used this  viewer to convert json to csv and this app to save xml to csv

2. I used this PowerShell to show difference between two csv files:


Start-Transcript -Path result-10.csv


$mas = Import-Csv 1.csv
$marko = Import-Csv 2.csv

$md=@{}
#converting one csv into hashmap for quicker search
foreach($r in $mas){
    foreach($a in $r.psobject.properties){
        $fn=$a.name
        $val=$a.value
        $md.Add($fn.ToLower(),$val)
    }
}

echo "fieldName,csv1,csv2"

    foreach($r in $marko){
        foreach($a in $r.psobject.properties){

            $k=$a.name.replace("_","").toLower()
            if ($md.ContainsKey($k)){
                if ($md[$k] -ne $a.value){
                  echo "$($a.name),$($a.value),$($md[$k])"
                }
            }
        }
    }
Stop-Transcript

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...