Skip to content

Commit 8bd5fc7

Browse files
committed
Add is_image to property pool
1 parent 42152c8 commit 8bd5fc7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ Tricky examples of the property expansion:
134134
| `path` | `string` | full source path - may be a network path, so beware |
135135
| `pos` | `number` | Current playback position (float), format it with `${#pos:TIMEFORMAT}`! |
136136
| `unique` | `number` | A sequence number. The script will choose the first available filename, starting with `unique` as 1 and counting up. Use with `${%...}` |
137-
| `full` | `boolean` | Flag to specify which filename is being expanded - the cropped (`false`) output or the intermediary full-size image (`true`). Use with `${?...}` and `${-...}` |
137+
| `full` | `boolean` | Flag to specify which filename is being expanded - the cropped (`false`) output or the intermediary full-size image (`true`). Use with `${?...}` and `${!...}` |
138+
| `is_image` | `boolean` | Flag to tell if the current file is likely an image. Use with `${?...}` and `${!...}` |
138139
| `crop_w` | `number` | Width of the crop |
139140
| `crop_h` | `number` | Height of the crop |
140141
| `crop_x` | `number` | Left edge of the crop |

src/main.lua

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ end
4040
function expand_output_path(cropbox)
4141
local filename = mp.get_property_native("filename")
4242
local playback_time = mp.get_property_native("playback-time")
43+
local duration = mp.get_property_native("duration")
4344

4445
local filename_without_ext, extension = filename:match("^(.+)%.(.-)$")
4546

@@ -52,6 +53,7 @@ function expand_output_path(cropbox)
5253
pos = mp.get_property_native("playback-time"),
5354

5455
full = false,
56+
is_image = (duration == 0 and playback_time == 0),
5557

5658
crop_w = cropbox.w,
5759
crop_h = cropbox.h,

src/options.lua

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ script_options:add_options({
2828
crop_x2 - right
2929
crop_y2 - bottom
3030
full - boolean denoting a full (temporary) screenshot instead of crop
31+
is_image - boolean denoting the source file is likely an image (zero duration and position)
3132
unique - counter that will increase per each existing filename, until a unique name is found]]},
3233

3334
{"output_format", "png",

0 commit comments

Comments
 (0)