All Projects → tomterl → metalsmith-convert

tomterl / metalsmith-convert

Licence: MIT license
Convert images with imagemagick (via imagemagick-native).

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to metalsmith-convert

converjon
An advanced image conversion server and command line tool.
Stars: ✭ 52 (+205.88%)
Mutual labels:  imagemagick, convert-images
FuzzImageMagick
Sample files for fuzzing ImageMagick
Stars: ✭ 15 (-11.76%)
Mutual labels:  imagemagick
Imgbot
An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. [email protected]
Stars: ✭ 1,017 (+5882.35%)
Mutual labels:  imagemagick
metalsmith-request
Metalsmith plugin to grab content from the web and expose the results to metadata
Stars: ✭ 12 (-29.41%)
Mutual labels:  metalsmith
EasyAlbum
📷 A lightweight, pure-Swift library for pick up photo from your album.
Stars: ✭ 31 (+82.35%)
Mutual labels:  imagemagick
metalsmith-paths
Metalsmith plugin that adds file path values to metadata
Stars: ✭ 19 (+11.76%)
Mutual labels:  metalsmith
mogrify
Image processing in Elixir (ImageMagick command line wrapper)
Stars: ✭ 525 (+2988.24%)
Mutual labels:  imagemagick
codeigniter-image-magician
🎨 An ImageMagick library for CodeIgniter.
Stars: ✭ 13 (-23.53%)
Mutual labels:  imagemagick
MagickSlicer
Map tiles generator
Stars: ✭ 73 (+329.41%)
Mutual labels:  imagemagick
slitcamera
Bash script to turn video file into slit photo
Stars: ✭ 41 (+141.18%)
Mutual labels:  imagemagick
RobotEyes
Image comparison for Robot Framework
Stars: ✭ 62 (+264.71%)
Mutual labels:  imagemagick
resizer
Quick image resizer app for elementary OS
Stars: ✭ 15 (-11.76%)
Mutual labels:  imagemagick
directus-metalsmith-snipcart
Lookbook web app with Directus' open source headless CMS, Metalsmith, Vue.js & Snipcart
Stars: ✭ 14 (-17.65%)
Mutual labels:  metalsmith
metalsmith-imagemin
Metalsmith plugin to minify images
Stars: ✭ 17 (+0%)
Mutual labels:  metalsmith
RCE-python-oneliner-payload
Python bind shell single line code for both Unix and Windows, used to find and exploit RCE (ImageMagick, Ghostscript, ...)
Stars: ✭ 23 (+35.29%)
Mutual labels:  imagemagick
remove
A Metalsmith plugin to remove files from the build
Stars: ✭ 19 (+11.76%)
Mutual labels:  metalsmith
FotoKilof
GUI for ImageMagick
Stars: ✭ 114 (+570.59%)
Mutual labels:  imagemagick
blurlock-neofetch
A standard i3lock blur screen, but now with neofetch stats overlayed
Stars: ✭ 17 (+0%)
Mutual labels:  imagemagick
retropixels
A cross platform tool to convert images to c64 format.
Stars: ✭ 78 (+358.82%)
Mutual labels:  convert-images
lambda-resize-image
An AWS Lambda Function to resize images automatically with API Gateway and S3 for imagemagick tasks. When an image is called on AWS Api Gateway, this package will resize it and send it to the S3.
Stars: ✭ 56 (+229.41%)
Mutual labels:  imagemagick

Is anybody using this?

Because I am not :)

If somebody other than me could take over as maintainer, in case there are users, that would be very welcome. Security and usability would benefit, I think.

metalsmith-convert

This is a plugin for Metalsmith that uses node-imagemagick-native to convert image-files

Installation

This module is released via npm, install the latest released version with

npm install --save metalsmith-convert

Dependencies

This module uses node-imagemagick-native. You must be able to compile c++ code to install imagemagick-native. The Readme provides instructions for Linux, Mac OS X and Windows respectively.

Usage

If using the CLI for Metalsmith, metalsmith-convert can be used like any other plugin by including it in metalsmith.json. For example:

{
  "plugins": {
    "metalsmith-convert": {
      "src": "**/*.svg",
      "target": "png"
    }
  }
}

For metalsmiths JavaScript API, metalsmith-convert can be used like any other plugin, by attaching it to the function invocation chain on the metalsmith object. For example:

var convert = require('metalsmith-convert');
require('metalsmith')(__dirname)
  .use(convert({
    src: '**/*.svg',
    target: 'png'
  })
  .build();

Options

metalsmith-convert requires the src options. The parameter target is optional; if it is not given, files will be converted to the source-format.

  • src is a globbing pattern that specifies which files to convert
  • target is an imagemagick format specifier
  • extension the file extension to use for the conversion target (starting with .). Set to "." + target if not given explicitly.
  • remove if set to true, don't include the source-file in the build directory.
  • resize set to {width: XXX, height: YYY} to resize the image; the name will reflect the size (name_XXX_YYY.ext) if nameFormat is not given.
    • resizeStyle: optional. default: 'aspectfill'. can be 'aspectfit','fill'. Must be added as a parameter to the resize option.
      • aspectfill: keep aspect ratio, get the exact provided size.
      • aspectfit: keep aspect ratio, get maximum image that fits inside provided size
      • fill: forget aspect ratio, get the exact provided size
  • rename_only: if set to true, omits the call to ImageMagick and only moves the files to their intended target.
  • nameFormat: the format for the names of the converted files, the following placeholders are available
    • %b the basename of the source file, e.g. given source.png, the value will be source
    • %e the extension of the target format, including the dot
    • %x the width of the resulting image
    • %y the height if the resulting image
  • renameSourceFormat: the name-format to rename the source files in the result/build to. Accepts the same place-holders as nameFormat.

The plugin also forwards certain options directly to imagemagick-native, these options are density, blur, rotate, flip, strip, gravity and quality. See imagemagick-native docs for more info.

  • It is possible to pass options as array of option-objects to implement multiple rules, e.g. resize to two sizes for different thumbnail sizes:
{
  "plugins": {
    "metalsmith-convert": [
      {
        "src": "**/*.svg",
        "target": "png",
        "resize": {width: 320, height: 240},
        "nameFormat": "%b_thumb%e"
      },
      {
        "src": "**/*.svg",
        "target": "png",
        "resize": {width: 640, height: 480, resizeStyle: 'aspectfit'},
        "nameFormat": "%b_thumb_large%e"
      }
    ]
  }
}
  • Resize images without format conversion:
{
  "plugins": {
    "metalsmith-convert":
      {
        "src": "**/*.svg",
        "resize": {width: 320, height: 240},
        "nameFormat": "%b_thumb%e"
      },
  }
}
  • Convert to the source name, but keep the original under a different name:
{
  "plugins": {
    "metalsmith-convert":
      {
        "src": "**/*.svg",
        "resize": {width: 320, height: 240},
        "nameFormat": "%b_thumb%e"
        "renameSourceFormat": "%b_orig_%e"
      },
  }
}

Development

To speed up your development cycle you can use the rename_only option, pictures will not be processed and have a potentially wrong file ending, but if your setup can cope with that, on demand scaling might be preferable to longer conversion times.

Contributions

Contributions are always welcome. Just make sure that all tests pass before sending a pull request. And don't forget to add tests for your contributions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].