Skip to content

Commit

Permalink
docs: add process_cmd option
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes committed Mar 24, 2024
1 parent 841d8d9 commit 4dc8a6d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The plugin comes with the following defaults:
default = {
dir_path = "assets", -- directory path to save images to, can be relative (cwd or current file) or absolute
file_name = "%Y-%m-%d-%H-%M-%S", -- file name format (see lua.org/pil/22.1.html)
process_cmd = "", -- shell command to process the image before saving or embedding as base64 (e.g. "convert -quality 85 - -")
url_encode_path = false, -- encode spaces and special characters in file path
use_absolute_path = false, -- expands dir_path to an absolute path
relative_to_current_file = false, -- make dir_path relative to current file rather than the cwd
Expand Down Expand Up @@ -182,6 +183,20 @@ dir_path = function()
end,
```

### Processing images

The `process_cmd` option allows you to specify a shell command to process the image before saving or embedding it as base64. The command should read the image data from the standard input and write the processed data to the standard output.

Examples:

```bash
process_cmd = "convert - -quality 85 -" -- compress the image with 85% quality
process_cmd = "convert - -resize 50% -" -- resize the image to 50% of its original size
process_cmd = "convert - -colorspace Gray -" -- convert the image to grayscale
```

Ensure the specified command and its dependencies are installed and accessible in your system's shell environment. The above examples require [ImageMagick](https://imagemagick.org/index.php) to be installed.

### Filetypes

Filetype specific options will override the default (or global) configuration.
Expand Down
2 changes: 1 addition & 1 deletion lua/img-clip/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local defaults = {
default = {
dir_path = "assets", -- directory path to save images to, can be relative (cwd or current file) or absolute
file_name = "%Y-%m-%d-%H-%M-%S", -- file name format (see lua.org/pil/22.1.html)
process_cmd = "",
process_cmd = "", -- shell command to process the image before saving or embedding as base64 (e.g. "convert -quality 85 - -")
url_encode_path = false, -- encode spaces and special characters in file path
use_absolute_path = false, -- expands dir_path to an absolute path
relative_to_current_file = false, -- make dir_path relative to current file rather than the cwd
Expand Down
15 changes: 15 additions & 0 deletions vimdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The plugin comes with the following defaults:
default = {
debug = false, -- enable debug mode
dir_path = "assets", -- directory path to save images to, can be relative (cwd or current file) or absolute
process_cmd = "", -- shell command to process the image before saving or embedding as base64 (e.g. "convert -quality 85 - -")
file_name = "%Y-%m-%d-%H-%M-%S", -- file name format (see lua.org/pil/22.1.html)
url_encode_path = false, -- encode spaces and special characters in file path
use_absolute_path = false, -- expands dir_path to an absolute path
Expand Down Expand Up @@ -173,6 +174,20 @@ dir_path = function()
end,
```

### Processing images

The `process_cmd` option allows you to specify a shell command to process the image before saving or embedding it as base64. The command should read the image data from the standard input and write the processed data to the standard output.

Examples:

```bash
process_cmd = "convert - -quality 85 -" -- compress the image with 85% quality
process_cmd = "convert - -resize 50% -" -- resize the image to 50% of its original size
process_cmd = "convert - -colorspace Gray -" -- convert the image to grayscale
```

Ensure the specified command and its dependencies are installed and accessible in your system's shell environment. The above examples require [ImageMagick](https://imagemagick.org/index.php) to be installed.

### Filetypes

Filetype specific options will override the default (or global) configuration.
Expand Down

0 comments on commit 4dc8a6d

Please sign in to comment.