Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image-script #1123

Closed
foresterre opened this issue Mar 31, 2022 · 0 comments
Closed

image-script #1123

foresterre opened this issue Mar 31, 2022 · 0 comments

Comments

@foresterre
Copy link
Owner

foresterre commented Mar 31, 2022

type Image = internal 'Image<InputMetadata>';
type Set[T] = internal 'Set';
type Seq[T] = internal 'Seq';

fn Image.resize = (image: Image) => image
  |> call_internal 'ImageOps::resize'; 

struct Image<Meta> {
  buffer: DynamicImage
  meta: Meta, 
}

enum InputMetadata {
	FromSource(FromSourceMeta),
	Erased,
}

struct FromSourceMeta {
 source: Source,
 ...
}

enum Source {
	Stdin,
	Path(PathBuf),
}
m := Input.read "media/input.png"; #type: fn(Path) => Image
s := Input.read_glob "media/*.jpeg"; #type: fn(GlobPath) => Set[Image]

m' := m # new pipeline
|> Image.resize {x: 480, y: 720} # input type Image, with `argument_map { required: {x: usize, y: usize} }, optional: {}}` #type: fn(Image, {x: usize, y: usize}) => Image 
|> Seq.repeat #type: fn(Image) => Seq[Image]
|> Seq.map (image) => ... #type: fn(Seq[Image], fn(Image) => Image) => Seq[Image]
|> Animate.fromSeq #type fn(Seq[Image] => AnimatedImage);

Output.write m' { path: "media/output/dance.png", format: "apng") #type (into ImageBuffer => Unit)

Experimental.unlock Info.print;

Set.each (image) => Info.print image.meta.path;

Output.write_all s { folder: 'media/output', format: 'png' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant