User:Amy Suo Wu/dummies, the sequel: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "==10th Nov ==28th Oct. tile distort with imagemagick and cronjob == [http://pzwart3.wdka.hro.nl/~awu/tile_distort.jpg weather prediction] weather distortions ==21th Oct. I...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==10th Nov
==10th Nov. Animations ==
*[http://pzwart3.wdka.hro.nl/~awu/distort.mp4 spinning maria]
*[http://pzwart3.wdka.hro.nl/~awu/distort2.mp4 spinning tiger]
*[http://pzwart3.wdka.hro.nl/~awu/distort3.mp4 spinning tiger2]
*[http://pzwart3.wdka.hro.nl/~awu/distort5.mp4 spinning tiger3] looping
*[http://pzwart3.wdka.hro.nl/~awu/weather.mp4 hurricane amy] looping


==28th Oct. tile distort with imagemagick and cronjob ==
[http://pzwart3.wdka.hro.nl/~awu/tile_distort.jpg weather prediction]
[[weather distortions]]


==21th Oct. I Command line! ==
anim.py
<source lang = "python">
from magickwand import *
from ctypes import *
import random
import sys
 
duration = 2
fps = 15
transitions = 2
width = 640
height = 480
frame_num = 1
prefix = 'distort.'
extension = '.jpg'
inputfile = 'maria.jpg'
 
 
def loop():           
    distortion_A = generate_distortion()
    distortion_B = generate_distortion()
    generate_transition(distortion_A, distortion_B)
    generate_transition(distortion_B, distortion_A)
 
 
 
def generate_distortion():
    x_offset = random.randint(0,width)
    y_offset = random.randint(0,height)
    angle = random.randint(5,360)
    rotation = 0
    topradius = random.randint(1,height)
 
    distortion_params = [x_offset, y_offset, angle,rotation,topradius]
 
    return distortion_params
 
def generate_animation():
 
    for i in range(transitions):
        if i == 0:
            distortion_A = generate_distortion()
        else:
            distortion_A = distortion_B
        distortion_B = generate_distortion()
        generate_transition(distortion_A, distortion_B)
 
 
def generate_transition(distortion_A, distortion_B):
    fpt = (duration * fps) / transitions
 
    x_offset_step = (distortion_B[0] - distortion_A[0]) / fpt
    y_offset_step = (distortion_B[1] - distortion_A[1]) / fpt
    angle_step = (distortion_B[2] - distortion_A[2]) / fpt
    rotation_step = (distortion_B[3] - distortion_A[3]) / fpt
    topradius_step = (distortion_B[4] - distortion_A[4]) / fpt
 
    x_offset = distortion_A[0]
    y_offset = distortion_A[1]
    angle = distortion_A[2]
    rotation = distortion_A[3]
    topradius = distortion_A[4]
 
    for i in range(fpt):
        if i > 0 :
            x_offset += x_offset_step
            y_offset += y_offset_step
            angle += angle_step
            rotation += rotation_step
            topradius += topradius_step
 
        generate_image(x_offset, y_offset, angle, rotation, topradius)
        global frame_num
        frame_num += 1       
 
def generate_image(x_offset, y_offset, angle, rotation, topradius):
    arrayType = c_double * 3
    args = arrayType()
    args[0] = c_double(angle)
    args[1] = c_double(rotation)
    args[2] = c_double(topradius)
   
    viewport = '%ix%i-%i-%i' % (width, height, x_offset, y_offset)
 
    wand = NewMagickWand()
    MagickReadImage(wand,inputfile)
    MagickSetImageArtifact(wand,'distort:viewport',viewport)
    MagickSetImageVirtualPixelMethod(wand,TileVirtualPixelMethod)
    MagickDistortImage(wand,ArcDistortion, 3, args, MagickTrue)
 
    filename = '%s%05d%s' % (prefix,frame_num,extension)
    MagickWriteImage(wand,filename)
 
 
def usage():
print 'please provide a path to the image : python anim.py myimage.jpg'
 
 
 
def main():
try:
global inputfile
inputfile = sys.argv[1]
loop()
#generate_animation()
except:
usage()
main()
 
</source>
 
 
'''permissions on the server'''
 
 
-rwxr-xr-x
user group other (ugo)
 
to add permission +
 
to take away permission -
 
example:
chmod go+w means that you give and group and other 'write' permissions.
 
 
 
 
==28th Oct. Tile distort with imagemagick and cronjobs ==
[[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][http://pzwart3.wdka.hro.nl/~awu/tile_distort.jpg '''today's weather forecast is........'''] [[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]][[image:Rain.png]]
 
*[[weather distortions]]
 
 
[http://www.imagemagick.org/Usage/canvas/#tile handy tips on imagemagick]
 
 
 
==21st Oct. I Command line! ==


<source lang = "bash">
<source lang = "bash">

Latest revision as of 18:16, 17 November 2011

10th Nov. Animations


anim.py

from magickwand import *
from ctypes import *
import random
import sys

duration = 2
fps = 15
transitions = 2
width = 640
height = 480
frame_num = 1
prefix = 'distort.'
extension = '.jpg'
inputfile = 'maria.jpg'


def loop():            
    distortion_A = generate_distortion()
    distortion_B = generate_distortion()
    generate_transition(distortion_A, distortion_B)
    generate_transition(distortion_B, distortion_A)



def generate_distortion():
    x_offset = random.randint(0,width)
    y_offset = random.randint(0,height)
    angle = random.randint(5,360)
    rotation = 0
    topradius = random.randint(1,height)

    distortion_params = [x_offset, y_offset, angle,rotation,topradius]

    return distortion_params

def generate_animation():

    for i in range(transitions):
        if i == 0:
            distortion_A = generate_distortion()
        else:
            distortion_A = distortion_B
        distortion_B = generate_distortion()
        generate_transition(distortion_A, distortion_B)


def generate_transition(distortion_A, distortion_B):
    fpt = (duration * fps) / transitions

    x_offset_step = (distortion_B[0] - distortion_A[0]) / fpt
    y_offset_step = (distortion_B[1] - distortion_A[1]) / fpt
    angle_step = (distortion_B[2] - distortion_A[2]) / fpt
    rotation_step = (distortion_B[3] - distortion_A[3]) / fpt
    topradius_step = (distortion_B[4] - distortion_A[4]) / fpt

    x_offset = distortion_A[0]
    y_offset = distortion_A[1]
    angle = distortion_A[2]
    rotation = distortion_A[3]
    topradius = distortion_A[4]

    for i in range(fpt):
        if i > 0 :
            x_offset += x_offset_step
            y_offset += y_offset_step
            angle += angle_step
            rotation += rotation_step
            topradius += topradius_step

        generate_image(x_offset, y_offset, angle, rotation, topradius)
        global frame_num
        frame_num += 1        

def generate_image(x_offset, y_offset, angle, rotation, topradius):
    arrayType = c_double * 3
    args = arrayType()
    args[0] = c_double(angle)
    args[1] = c_double(rotation)
    args[2] = c_double(topradius)
    
    viewport = '%ix%i-%i-%i' % (width, height, x_offset, y_offset)

    wand = NewMagickWand()
    MagickReadImage(wand,inputfile)
    MagickSetImageArtifact(wand,'distort:viewport',viewport)
    MagickSetImageVirtualPixelMethod(wand,TileVirtualPixelMethod)
    MagickDistortImage(wand,ArcDistortion, 3, args, MagickTrue)

    filename = '%s%05d%s' % (prefix,frame_num,extension)
    MagickWriteImage(wand,filename)


def usage():
	print 'please provide a path to the image : python anim.py myimage.jpg'



def main():
	try:
		global inputfile 
		inputfile = sys.argv[1]
		loop()
		#generate_animation()
	except:
		usage()
main()


permissions on the server


-rwxr-xr-x user group other (ugo)

to add permission +

to take away permission -

example: chmod go+w means that you give and group and other 'write' permissions.



28th Oct. Tile distort with imagemagick and cronjobs

Rain.pngRain.pngRain.pngRain.pngRain.pngRain.pngRain.pngtoday's weather forecast is........ Rain.pngRain.pngRain.pngRain.pngRain.pngRain.png


handy tips on imagemagick


21st Oct. I Command line!

ps ax = get a list of all processes running on the computer.

grep = search for a string

scp = secure copy
ssh = secure shell


ls = show me in folder
ls -al = all files (also hidden)
cp = copy (e.g cp ../../newmovie.mp4 . means to copy file two folders before here 
../../ is relative
* is wild card.

mv = move folder/file, or rename
mkdir = make directory
cd = change directory
rm = remove file
rm -rf = remove folder
rm -r = remove recursively. delete all contents incl folder

grep = find a string. (crawls for words in file)
grep "blah" "*"

find
man = manual

watch = timer. can do it to any file
-surveilling the file. command: e.g. watch cat poo.txt 3(e.g. txt) 
-This runs the command every 3 seconds.


./ = execute

sed = search and replace
cat = concatinate and print files (shows content of file and outputs in binary form)
echo = is echo
less = 


| = pipeline
> = output
>> = adding files.

ctrl + c


example:
ls -al ~
mv *.jpg ~/pics/
rm -rf pics
grep “bla” *
find -name “*bla*”
mkdir test
echo bla > bla.txt
echo blabla >> bla.txt
cat /var/log/auth.log |less