Skip to main content

ImageMagick preprocessor for Foliant.

Project description

# ImageMagick Preprocessor

This tool provides additional processing of images that referred in Markdown source, with [ImageMagick](https://imagemagick.org/).

## Installation

```bash
$ pip install foliantcontrib.imagemagick
```

## Config

To enable the preprocessor, add `imagemagick` to `preprocessors` section in the project config:

```yaml
preprocessors:
- imagemagick
```

The preprocessor has a number of options with the following default values:

```yaml
preprocessors:
- imagemagick:
convert_path: convert
cache_dir .imagemagickcache
```

`convert_path`
: Path to `convert` binary, a part of ImageMagick.

`cache_dir`
: Directory to store processed images. These files can be reused later.

## Usage

Suppose you want to apply the following command to your picture `image.eps`:

```bash
$ convert image.eps -resize 600 -background Orange label:'Picture' +swap -gravity Center -append image.jpg
```

This command takes the source EPS image `image.eps`, resizes it, puts a text label over the picture, and writes the result into new file `image.jpg`. The suffix of output file name specifies that the image must be converted into JPEG format.

To use the ImageMagick preprocessor to do the same, enclose one or more image references in your Markdown source between `<<magick>` and `</magick>` tags.

```markdown
<<magick command_params="-resize 600 -background Orange label:'Picture' +swap -gravity Center -append" output_format="jpg">
![Optional Caption](image.eps)
</magick>
```

Use `output_format` attribute to specify the suffix of output file name. The whole output file name will be generated automatically.

Use `command_params` attribute to specify the string of parameters that should be passed to ImageMagick `convert` binary.

Instead of using `command_params` attribute, you may specify each parameter as its own attribute with the same name:

```markdown
<<magick resize="600" background="Orange label:'Picture' +swap" gravity="Center" append="true" output_format="jpg">
![Optional Caption](image.eps)
</magick>
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

foliantcontrib.imagemagick-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file foliantcontrib.imagemagick-1.0.0.tar.gz.

File metadata

File hashes

Hashes for foliantcontrib.imagemagick-1.0.0.tar.gz
Algorithm Hash digest
SHA256 23027ba5bbdba664f8365342717aee971231d548b2ed18b681abcfdb843c246f
MD5 e43cfe5dbf5fa6ff0e5a8736e407340f
BLAKE2b-256 3ea466474946c979d2d4c61bd83d38d06c6acfc7c6c000da087bde3d32f4dee9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page