Skip to content

Commit

Permalink
Add is_image to property pool
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAMM committed May 10, 2018
1 parent 42152c8 commit 8bd5fc7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ Tricky examples of the property expansion:
| `path` | `string` | full source path - may be a network path, so beware |
| `pos` | `number` | Current playback position (float), format it with `${#pos:TIMEFORMAT}`! |
| `unique` | `number` | A sequence number. The script will choose the first available filename, starting with `unique` as 1 and counting up. Use with `${%...}` |
| `full` | `boolean` | Flag to specify which filename is being expanded - the cropped (`false`) output or the intermediary full-size image (`true`). Use with `${?...}` and `${-...}` |
| `full` | `boolean` | Flag to specify which filename is being expanded - the cropped (`false`) output or the intermediary full-size image (`true`). Use with `${?...}` and `${!...}` |
| `is_image` | `boolean` | Flag to tell if the current file is likely an image. Use with `${?...}` and `${!...}` |
| `crop_w` | `number` | Width of the crop |
| `crop_h` | `number` | Height of the crop |
| `crop_x` | `number` | Left edge of the crop |
Expand Down
2 changes: 2 additions & 0 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ end
function expand_output_path(cropbox)
local filename = mp.get_property_native("filename")
local playback_time = mp.get_property_native("playback-time")
local duration = mp.get_property_native("duration")

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

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

full = false,
is_image = (duration == 0 and playback_time == 0),

crop_w = cropbox.w,
crop_h = cropbox.h,
Expand Down
1 change: 1 addition & 0 deletions src/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ script_options:add_options({
crop_x2 - right
crop_y2 - bottom
full - boolean denoting a full (temporary) screenshot instead of crop
is_image - boolean denoting the source file is likely an image (zero duration and position)
unique - counter that will increase per each existing filename, until a unique name is found]]},

{"output_format", "png",
Expand Down

0 comments on commit 8bd5fc7

Please sign in to comment.