nuno-faria / tiler

👷 Build images with images
MIT License
5.89k stars 423 forks source link

Can I batch convert? #43

Closed acgloli closed 2 years ago

acgloli commented 2 years ago

I want to batch convert several images instead of selecting them one by one, and I don't know how to do it.

nuno-faria commented 2 years ago

You can if you build a script around the program. For example, consider that you want to tile all images in the folder images_to_tile. In Windows with Powershell, you can just paste the following code in the terminal:

Get-ChildItem ".\images_to_tile\" |
Foreach-Object { # for each file in the folder images_to_tile
  echo "Tiling $_"
  python tiler.py $_.FullName .\tiles\circles\gen_circle_100\ # run the tiling program; change here the type of tiles if you want
  mv -Force out.png "$($_.BaseName).png" # rename the output (out.png) to have the same name as the original image
  echo ""
}

If you instead use Linux or MacOS, you can run the following Bash script

for filename in images_to_tile/*; do # for each file in the folder images_to_tile
    echo "Tiling ${filename##*/}"
    python3 tiler.py $filename ./tiles/circles/gen_circle_100/ # run the tiling program; change here the type of tiles if you want
    mv out.png ${filename##*/} # rename the output (out.png) to have the same name as the original image
    echo ""
done

Let me know if this solved your issue.

acgloli commented 2 years ago

Thank you very much, successfully solved my problem!