---
title: "ImageMagick用外部配置文件处理图片"
author: "yzgfbj"
date: "2008-07-11T14:11:14Z"
tags: []
slug: "imagemagick"
draft: false
lastmod: "2008-07-11T14:11:14Z"
id: 213914
url: "https://yzgfbj.iteye.com/blog/213914"
---

今天项目需要，要加一组imageMagick处理图片的方式，就又看了imageMagick的文档。看到下面有个conjure命令，以前没有发现啊。
点击看了一下里面的介绍和例子：
Example Usage

We list a few examples of the conjure command here to illustrate its usefulness and ease of use. To get started, here is simple conjure command:

```command

  conjure -dimensions 400x400 incantation.msl

```

Where incantation.msl is our MSL script:

```xml

  <?xml version="1.0" encoding="UTF-8"?>
  <image size="400x400">
    <read filename="image.gif" />
    <get width="base-width" height="base-height" />
    <resize geometry="%[dimensions]" />
    <get width="width" height="height" />
    <print output="Image sized from %[base-width]x%[base-height] to %[width]x%[height].\n" />
    <write filename="image.png" />
  </image>

```

可以从外部配置文件生成图片处理，这样很多处理方式不用耦合到程序里面了。以后要加图片处理直接修改一下配置文件就可以了。
直接copy出来，试了一下，可以处理，但是参数怎么都穿不进去。试了几遍一直不成功。到官网上看了一下，有最新版的下载。看了我的版本6.2,直接下了最新6.4重新试了一下，成功。
不知道为什么6.2不行，他的文档里有介绍这样用的。
在<http://www.atmos.washington.edu/ImageMagick/conjure.html>可以看到msl(Magick Scripting Language)的配置格式。