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

How to batch process images? #127

Closed
whatacold opened this issue May 18, 2020 · 6 comments
Closed

How to batch process images? #127

whatacold opened this issue May 18, 2020 · 6 comments

Comments

@whatacold
Copy link

Hi,

Ronin is fantastic, it blows my mind, thanks for this piece of software.

I wonder if it's possible to batch process images, for example, below is the example/pixels/crop.lisp, is it possible to crop many images using it? If so, how?

; crop
(clear)
(open $path)
(crop 
  (rect 100 100 400 400))
@whatacold
Copy link
Author

Besides, is there any documentation about the Lain dialect? Especially about its APIs.

I found very little at https://wiki.xxiivv.com/site/lain.html, and I wonder if there is a loop or while control structure, so that it can be easy to do this batch processing.

@neauoire
Copy link
Member

Hi!

Sure, so make sure you have the latest version(I just pushed a new (files) helper that makes this a lot easier)

(clear)

(defn print-file 
  (name index) 
  (fill 
    (text 0 
      (add 
        (mul index 40) 50) 40 name) "red"))

(each 
  (files) print-file)

Screenshot from 2020-05-19 07-09-06@2x

You can find the list of functions here, you can find the declaration themselves here.

@whatacold
Copy link
Author

Thanks for the quick implementation of (files).

I'm sorry, but I'm a bit confused about how to use it, is it right to drag the target images one by one to the canvas, and then run the whole lisp script?

@whatacold
Copy link
Author

I'm also wondering if you would like to add a feature of eval'ing the last s-expr before the cursor :)

For example:

(debug "hello")
| ; <- the cursor is here
(debug "world")

So that if I click that menu or press the shortcut, it only print "hello" to the console.
I think it helps to make the lisp script incrementally.

neauoire added a commit that referenced this issue May 19, 2020
@neauoire
Copy link
Member

neauoire commented May 19, 2020

is it right to drag the target images one by one to the canvas, and then run the whole lisp script?

You can drag all of them at once, and cycle through them with (export). See video demo.

(clear)

(defn resize-file 
  (name index) 
  (do 
    (open name 0.5) 
    (fill 
      (circle 50 50 20) "red") 
    (export)))

(each 
  (files) resize-file)

I'm also wondering if you would like to add a feature of eval'ing the last s-expr before the cursor :)

I've added eval selection with alt+enter

@whatacold
Copy link
Author

This is so cool, thank you very much!

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

2 participants