summaryrefslogtreecommitdiff
path: root/slice.raku
diff options
context:
space:
mode:
Diffstat (limited to 'slice.raku')
-rwxr-xr-xslice.raku34
1 files changed, 29 insertions, 5 deletions
diff --git a/slice.raku b/slice.raku
index 124c230..f1af536 100755
--- a/slice.raku
+++ b/slice.raku
@@ -1,9 +1,30 @@
#!/usr/bin/env raku
class Image {
- has $.source;
- has $.thumb;
- has $.blur;
+ has Str $!source;
+ has Str $!thumb;
+ has Str $!blur;
+
+ submethod BUILD(IO::Path :$source, Str :$outdir) {
+ $!source = $source.path;
+ $!thumb = "$outdir/thumbs/{$source.basename}";
+ $!blur = "$outdir/blur/{$source.basename}";
+ }
+
+ multi method generate() {
+ self.generate(<-auto-orient -geometry 800>, dest => $!thumb)
+ unless $!thumb.IO.f;
+
+ self.generate(<-flip -blur 0x8>, dest => $!blur)
+ unless $!blur.IO.f;
+ }
+
+ multi method generate(Str :@args, Str :$dest) {
+ say @args;
+ @args.push: $!source;
+ @args.push: $dest;
+ say @args;
+ }
}
sub make-mrproper() {
@@ -12,7 +33,6 @@ sub make-mrproper() {
sub make-thumb(IO::Path $image, Str :$thumb-dir) {
my $thumb = "$thumb-dir/{$image.basename}";
return if $thumb.IO.f;
-
}
sub make-thumbs(:@images, Str :$outdir) {
@@ -30,5 +50,9 @@ multi MAIN(
my @images = dir($indir, test => { "$indir/$_".IO.f });
make-mrproper if $mrproper;
mkdir $outdir unless $outdir.IO.d;
- make-thumbs :@images, :$outdir;
+ #make-thumbs :@images, :$outdir;
+ @images.hyper(batch => 10).map({
+ my \image = Image.new(source => $_, :$outdir);
+ image.generate;
+ });
}