Skip to content

Commit aa2784d

Browse files
authored
Merge pull request #2 from MrLixm/refacto-image-crop-divide
refacto(icd): better image crop divide node
2 parents 06cc003 + 7215b55 commit aa2784d

16 files changed

+880
-975
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "foundry-nuke"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
description = "Collection of script & resources for Foundry's Nuke software."
55
authors = ["Liam Collod <monsieurlixm@gmail.com>"]
66
readme = "README.md"

src/imageCropDivide/ImageCropDivide.nk

Lines changed: 50 additions & 0 deletions
Large diffs are not rendered by default.

src/imageCropDivide/README.md

Lines changed: 86 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,104 @@
22

33
![Python](https://img.shields.io/badge/Python-2.7+-4f4f4f?labelColor=3776ab&logo=python&logoColor=FED142)
44

5-
From given maximum dimensions, divide an input image into multiples crops.
5+
Divide an image into multiple crops so it can be recombined later. This has some
6+
usefulness in the context of some nuke versions ...
67

78
![screenshot of the nodegraph in nuke](doc/img/nodegraph-cover.png)
89

9-
Compatible with:
10-
- Nuke Non-Commercial
11-
- Python > 2.7
12-
- Windows, Mac
10+
# requires
1311

14-
# Use
12+
- Nuke or Nuke Non-Commercial
13+
- Nuke with Python >= 2.7
14+
- All OS should be supported but was only tested on Windows.
1515

16-
The most straightforward setup is to paste/insert the [node.nk](node.nk) node
17-
into your nuke script, setup it and execute the script button.
16+
The combine feature requires `oiiotool` or `Pillow` to be availble on the
17+
system. See below for more information.
18+
19+
# Usage
20+
21+
- Copy/paste the content of [ImageCropDivide.nk](ImageCropDivide.nk) in Nuke.
1822

1923
![screenshot of the node in nuke](doc/img/node-img.png)
2024

21-
- Set the desired max dimensions and your source size.
25+
- Set the desired max dimensions and your source size if the defaults are not expected.
26+
- `Export Directory`: Set where the directory where the crops must be exported
27+
- `Combined File Name`: if you use the combine feature, name without the extension, of the combined file.
2228
- Click the `Copy ...` button
2329
- press ctrl+v to paste the node setup in the nodegraph.
24-
- On any of the Write node, modify the settings for export.
30+
- connect the top write node to the same node as the imageCropDivide node
31+
- On any of the cloned Write node, modify the settings for export as desired.
2532
- Unclone all the Write nodes `(Alt + shift + K)`
33+
- Render all the Write nodes
34+
- Once finished you have the option to combine the exported crops. See below
35+
for details.
36+
37+
> [!WARNING]
38+
> it seems that changing the file type of cloned write node make nuke crash
39+
> so you might have to unclone first and propagate changes on all write nodes :/
40+
41+
# combining
42+
43+
Combining will find ALL images in the `Export Directory` and combine them to
44+
a single image named using `Combined File Name` knob value.
45+
46+
> [!WARNING]
47+
> make sure the `Export Directory` doesn't contain anything else than
48+
> the crop you just exported before combining.
49+
50+
Combining require external softwares. Different options are available and
51+
automatically detected.
52+
53+
Here are the option in their order of priority :
54+
55+
## oiiotool
56+
57+
Recommended option. Use the `oiiotool.exe` CLI from OpenImageIO to combine back the crops.
58+
59+
You can specify the path to the oiiotool executable in 2 ways :
60+
- environment variable `OIIOTOOL`
61+
- the `oiiotool path` knob on the node
62+
63+
> [!TIP]
64+
> You can find it in the Arnold render-engine installation like
65+
> `C:\Program Files\Autodesk\Arnold\maya{VERSION}\bin`
66+
>
67+
> Or alternatively [get it from here](https://www.patreon.com/posts/openimageio-oiio-63609827) (has more plugin support)
68+
69+
70+
## Pillow
71+
72+
A python library for image processing. It work for simple case but suck
73+
for anything else (anything not 8bit).
74+
75+
It simply requires Pillow to be importable in the python context (`from PIL import Image`).
76+
77+
78+
# faq
79+
80+
> Why is there a ModifyMetadata node ?
81+
82+
This is the only way I found for now to have a different suffix per Write
83+
node and have them cloned at start. I could remove them and set directly the
84+
suffix on each unique Write node but then it would be a pain to modify one setting
85+
on all the write nodes.
86+
87+
# Developer
88+
89+
Instructions to develop the node.
90+
91+
[ImageCropDivide.nk](ImageCropDivide.nk) is the result of a build process defined
92+
in [src/](src).
93+
94+
It consist of combining nk file templates (because they have variables) with
95+
python scripts to form a single `.nk` node.
96+
97+
To build the node simply execute [build.py](src/build.py) from any python 3
98+
interpreter.
99+
100+
File suffixed with `-template` contained variable replaced during build.
101+
Variables have the syntax `%VARIABLE_NAME%`.
26102

27-
_Why is there a ModifyMetadata node ?_
28-
> This is the only way I found for now to have a different suffix per Write
29-
> node and have them cloned at start. I could remove them and set directly the
30-
> suffix on each unique Write node but then it would be a pain to modify one setting
31-
> on all the write nodes.
32103

33104
# Licensing
34105

0 commit comments

Comments
 (0)