Jpegloop: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 1: Line 1:
== Loop ==
== Counting up ==
Counting up...
<source lang="bash">
for ((i=1;i<=100;i++))
do
echo $i
done
</source>


== Counting down ==
<source lang="bash">
<source lang="bash">
for ((i=1;i<=100;i++))
for ((i=1;i<=100;i++))
Line 9: Line 15:
</source>
</source>


== Doing something ==
<source lang="bash">
for ((i=1;i<=10;i++))
do
convert original.jpg -quality $i output$i.jpg
done
</source>
== Fixing the filenames (zero padding with printf) ==
$() means "command substitution" -- or do what's inside the parentheses and then substitute the result


<source lang="bash">
<source lang="bash">
for ((i=100;i>=1;i--))
for ((i=1;i<=10;i++))
do
do
name=$(printf "%03d\n" $i)
name=$(printf "%03d\n" $i)
convert original.jpg -quality $i output$name.jpg
convert original.jpg -quality $i output$name.jpg

Revision as of 15:48, 4 March 2013

Counting up

for ((i=1;i<=100;i++))
do
echo $i
done

Counting down

for ((i=1;i<=100;i++))
do
echo $i
done

Doing something

for ((i=1;i<=10;i++))
do
convert original.jpg -quality $i output$i.jpg
done

Fixing the filenames (zero padding with printf)

$() means "command substitution" -- or do what's inside the parentheses and then substitute the result
for ((i=1;i<=10;i++))
do
name=$(printf "%03d\n" $i)
convert original.jpg -quality $i output$name.jpg
done

Basic Loop

cp $j lastframe.jpg

for ((i=100;i>=1;i--))
do

name=$(printf "%03d\n" $((100-i)))
convert lastframe.jpg -quality $i output$name.jpg
cp output$name.jpg lastframe.jpg

done

ffmpeg -f image2 -i output%03d.jpg -r 10 $j.mp4

Apply to a directory of files

#!/bin/bash

for j
do
cp $j lastframe.jpg

    for ((i=100;i>=1;i--))
    do

    name=$(printf "%03d\n" $((100-i)))
    convert lastframe.jpg -quality $i output$name.jpg
    # COPY THE CURRENT TO "lastframe.jpg"
    cp output$name.jpg lastframe.jpg

    
    done
    ffmpeg -f image2 -i output%03d.jpg -r 10 $j.mp4

done