From 405640e569d152570602c269bbcb97a1abedacb4 Mon Sep 17 00:00:00 2001 From: Kevin Gravier Date: Wed, 17 Jan 2018 23:26:01 -0500 Subject: [PATCH] More Typescript re-write work Renamed many files Refactored tests --- CHANGELOG.md | 3 + README.md | 8 +- docs/classes/baddestinationerror.html | 2 +- docs/classes/imagemagickmissingerror.html | 2 +- docs/classes/missingextensionerror.html | 2 +- docs/classes/missingoptionserror.html | 2 +- docs/classes/unsupportederror.html | 2 +- docs/globals.html | 26 +- docs/index.html | 26 +- docs/interfaces/ibaseoptions.html | 14 +- docs/interfaces/iconvertoptions.html | 14 +- docs/interfaces/icropoptions.html | 28 +- docs/interfaces/idensity.html | 4 +- .../interfaces/iimagemagickcommandresult.html | 4 +- docs/interfaces/iinforesult.html | 20 +- docs/interfaces/irescropoptions.html | 36 +- docs/interfaces/iresizeoptions.html | 22 +- docs/interfaces/irotateoptions.html | 16 +- docs/interfaces/ithumbnailoptions.html | 26 +- lib/EasyImage.js | 28 -- lib/{Commands => commands}/convert.js | 14 +- lib/{Commands => commands}/crop.js | 20 +- lib/{Commands => commands}/info.js | 6 +- lib/{Commands => commands}/rescrop.js | 18 +- lib/{Commands => commands}/resize.js | 14 +- lib/{Commands => commands}/rotate.js | 14 +- lib/{Commands => commands}/thumbnail.js | 16 +- lib/easyimage.js | 28 ++ lib/{Errors => errors}/BadDestinationError.js | 0 .../ImageMagickMissingError.js | 0 .../MissingExtensionError.js | 0 lib/{Errors => errors}/MissingOptionsError.js | 0 lib/{Errors => errors}/UnsupportedError.js | 0 lib/{ImageMagick.js => execute.js} | 4 +- lib/{Options.js => options.js} | 0 lib/{Utilities.js => utilities.js} | 6 +- package-lock.json | 327 +++++++++++++++++ package.json | 19 +- src/EasyImage.ts | 27 -- src/{Commands => commands}/convert.ts | 6 +- src/{Commands => commands}/crop.ts | 12 +- src/{Commands => commands}/info.ts | 4 +- src/{Commands => commands}/rescrop.ts | 11 +- src/{Commands => commands}/resize.ts | 6 +- src/{Commands => commands}/rotate.ts | 6 +- src/{Commands => commands}/thumbnail.ts | 6 +- src/easyimage.ts | 27 ++ src/{Errors => errors}/BadDestinationError.ts | 0 .../ImageMagickMissingError.ts | 0 .../MissingExtensionError.ts | 0 src/{Errors => errors}/MissingOptionsError.ts | 0 src/{Errors => errors}/UnsupportedError.ts | 0 src/{ImageMagick.ts => execute.ts} | 4 +- src/{Options.ts => options.ts} | 0 src/{Utilities.ts => utilities.ts} | 8 +- test/files/tall.png | Bin 0 -> 3556 bytes test/{ => files}/test.pdf | Bin test/files/wide.jpg | Bin 0 -> 5577 bytes test/files/wide.png | Bin 0 -> 3565 bytes test/specs/convert.spec.ts | 125 +++++++ test/specs/crop.spec.ts | 78 +++++ test/specs/easyimage.spec.ts | 65 ++++ test/specs/info.spec.ts | 54 +++ test/specs/rescrop.spec.ts | 53 +++ test/specs/resize.spec.ts | 224 ++++++++++++ test/specs/rotate.spec.ts | 51 +++ test/specs/thumbail.spec.ts | 52 +++ test/test.js | 330 ------------------ test/yolo-tall.png | Bin 762 -> 0 bytes test/yolo.png | Bin 1555 -> 0 bytes tsconfig.json | 2 +- types/EasyImage.d.ts | 13 - types/{Commands => commands}/convert.d.ts | 2 +- types/{Commands => commands}/crop.d.ts | 2 +- types/{Commands => commands}/info.d.ts | 0 types/{Commands => commands}/rescrop.d.ts | 0 types/{Commands => commands}/resize.d.ts | 2 +- types/{Commands => commands}/rotate.d.ts | 2 +- types/{Commands => commands}/thumbnail.d.ts | 2 +- types/easyimage.d.ts | 13 + .../BadDestinationError.d.ts | 0 .../ImageMagickMissingError.d.ts | 0 .../MissingExtensionError.d.ts | 0 .../MissingOptionsError.d.ts | 0 .../{Errors => errors}/UnsupportedError.d.ts | 0 types/{ImageMagick.d.ts => execute.d.ts} | 0 types/{Options.d.ts => options.d.ts} | 0 types/{Utilities.d.ts => utilities.d.ts} | 2 +- 88 files changed, 1344 insertions(+), 616 deletions(-) delete mode 100644 lib/EasyImage.js rename lib/{Commands => commands}/convert.js (73%) rename lib/{Commands => commands}/crop.js (74%) rename lib/{Commands => commands}/info.js (93%) rename lib/{Commands => commands}/rescrop.js (80%) rename lib/{Commands => commands}/resize.js (83%) rename lib/{Commands => commands}/rotate.js (74%) rename lib/{Commands => commands}/thumbnail.js (86%) create mode 100644 lib/easyimage.js rename lib/{Errors => errors}/BadDestinationError.js (100%) rename lib/{Errors => errors}/ImageMagickMissingError.js (100%) rename lib/{Errors => errors}/MissingExtensionError.js (100%) rename lib/{Errors => errors}/MissingOptionsError.js (100%) rename lib/{Errors => errors}/UnsupportedError.js (100%) rename lib/{ImageMagick.js => execute.js} (97%) rename lib/{Options.js => options.js} (100%) rename lib/{Utilities.js => utilities.js} (94%) delete mode 100644 src/EasyImage.ts rename src/{Commands => commands}/convert.ts (88%) rename src/{Commands => commands}/crop.ts (88%) rename src/{Commands => commands}/info.ts (96%) rename src/{Commands => commands}/rescrop.ts (88%) rename src/{Commands => commands}/resize.ts (93%) rename src/{Commands => commands}/rotate.ts (89%) rename src/{Commands => commands}/thumbnail.ts (93%) create mode 100644 src/easyimage.ts rename src/{Errors => errors}/BadDestinationError.ts (100%) rename src/{Errors => errors}/ImageMagickMissingError.ts (100%) rename src/{Errors => errors}/MissingExtensionError.ts (100%) rename src/{Errors => errors}/MissingOptionsError.ts (100%) rename src/{Errors => errors}/UnsupportedError.ts (100%) rename src/{ImageMagick.ts => execute.ts} (95%) rename src/{Options.ts => options.ts} (100%) rename src/{Utilities.ts => utilities.ts} (92%) create mode 100644 test/files/tall.png rename test/{ => files}/test.pdf (100%) create mode 100644 test/files/wide.jpg create mode 100644 test/files/wide.png create mode 100644 test/specs/convert.spec.ts create mode 100644 test/specs/crop.spec.ts create mode 100644 test/specs/easyimage.spec.ts create mode 100644 test/specs/info.spec.ts create mode 100644 test/specs/rescrop.spec.ts create mode 100644 test/specs/resize.spec.ts create mode 100644 test/specs/rotate.spec.ts create mode 100644 test/specs/thumbail.spec.ts delete mode 100644 test/test.js delete mode 100644 test/yolo-tall.png delete mode 100644 test/yolo.png delete mode 100644 types/EasyImage.d.ts rename types/{Commands => commands}/convert.d.ts (87%) rename types/{Commands => commands}/crop.d.ts (95%) rename types/{Commands => commands}/info.d.ts (100%) rename types/{Commands => commands}/rescrop.d.ts (100%) rename types/{Commands => commands}/resize.d.ts (94%) rename types/{Commands => commands}/rotate.d.ts (90%) rename types/{Commands => commands}/thumbnail.d.ts (94%) create mode 100644 types/easyimage.d.ts rename types/{Errors => errors}/BadDestinationError.d.ts (100%) rename types/{Errors => errors}/ImageMagickMissingError.d.ts (100%) rename types/{Errors => errors}/MissingExtensionError.d.ts (100%) rename types/{Errors => errors}/MissingOptionsError.d.ts (100%) rename types/{Errors => errors}/UnsupportedError.d.ts (100%) rename types/{ImageMagick.d.ts => execute.d.ts} (100%) rename types/{Options.d.ts => options.d.ts} (100%) rename types/{Utilities.d.ts => utilities.d.ts} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b8bf0..bba4757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ 7. Added `coalesce` option to all commands 8. Added orientation to `info()` 9. Changed `resize()` to not auto-set height from width +10. Added `getImageMagickVersion()` +11. Rewrote tests to be more clear + 2.2.0 - 10-01-2018 ------------------ diff --git a/README.md b/README.md index 95af25b..ed22c45 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,10 @@ any of the parameters defined on `IBaseOptions`. For example, to prevent EasyIma command. Every command must have a `src` parameter. If you do not specify a `dst`, then a random file will be created. Be sure to clean up randomly created files by -either moving them to permanent storage, or deleting them. Some command have other required options. +either moving them to permanent storage, or deleting them. Some commands have other required options. -The examples below only specify the required arguments. See the [Docs](https://mrkmg.github.io/node-easyimage/index.html) for all available options for each -command. +The examples below only specify some of the available arguments. See the [Docs](https://mrkmg.github.io/node-easyimage/index.html) for all available options for +each command. ### Convert @@ -179,7 +179,7 @@ ImageMagick. ``` import {getImageMagickVersion} from "easyimage"; -const version = getImageMagickVersion(); +const version = await getImageMagickVersion(); ``` ## Error Handling diff --git a/docs/classes/baddestinationerror.html b/docs/classes/baddestinationerror.html index 08795ef..a3ea99b 100644 --- a/docs/classes/baddestinationerror.html +++ b/docs/classes/baddestinationerror.html @@ -1047,7 +1047,7 @@

constructor

  • Returns BadDestinationError

    diff --git a/docs/classes/imagemagickmissingerror.html b/docs/classes/imagemagickmissingerror.html index 52a6621..c5230fa 100644 --- a/docs/classes/imagemagickmissingerror.html +++ b/docs/classes/imagemagickmissingerror.html @@ -1047,7 +1047,7 @@

    constructor

  • Returns ImageMagickMissingError

    diff --git a/docs/classes/missingextensionerror.html b/docs/classes/missingextensionerror.html index c8ef300..63c7e09 100644 --- a/docs/classes/missingextensionerror.html +++ b/docs/classes/missingextensionerror.html @@ -1047,7 +1047,7 @@

    constructor

  • Parameters

    diff --git a/docs/classes/missingoptionserror.html b/docs/classes/missingoptionserror.html index 983977a..0add8ec 100644 --- a/docs/classes/missingoptionserror.html +++ b/docs/classes/missingoptionserror.html @@ -1047,7 +1047,7 @@

    constructor

  • Parameters

    diff --git a/docs/classes/unsupportederror.html b/docs/classes/unsupportederror.html index 37f59d1..962f1c0 100644 --- a/docs/classes/unsupportederror.html +++ b/docs/classes/unsupportederror.html @@ -1047,7 +1047,7 @@

    constructor

  • Parameters

    diff --git a/docs/globals.html b/docs/globals.html index 19517f9..50ad2d6 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -1005,9 +1005,9 @@

    Installation

    any of the parameters defined on IBaseOptions. For example, to prevent EasyImage from auto-orientating your image, you can pass autoOrient: false on any command.

    Every command must have a src parameter. If you do not specify a dst, then a random file will be created. Be sure to clean up randomly created files by - either moving them to permanent storage, or deleting them. Some command have other required options.

    -

    The examples below only specify the required arguments. See the Docs for all available options for each - command.

    + either moving them to permanent storage, or deleting them. Some commands have other required options.

    +

    The examples below only specify some of the available arguments. See the Docs for all available options for + each command.

    Convert

    The convert() command can convert an image file from one type to another.

    import {convert} from "easyimage";
    @@ -1092,7 +1092,7 @@ 

    Info

    ImageMagick.

    import {getImageMagickVersion} from "easyimage";
     
    -const version = getImageMagickVersion();
    +const version = await getImageMagickVersion();
     

    Error Handling

    There are 5 different types of errors that can be thrown.

      @@ -1191,7 +1191,7 @@

      convert

    • @@ -1219,7 +1219,7 @@

      crop

    • @@ -1247,7 +1247,7 @@

      execute

    • @@ -1281,7 +1281,7 @@

      getImageMagickVersion

    • @@ -1312,7 +1312,7 @@

      info

    • @@ -1343,7 +1343,7 @@

      rescrop

    • @@ -1371,7 +1371,7 @@

      resize

    • @@ -1399,7 +1399,7 @@

      rotate

    • @@ -1427,7 +1427,7 @@

      thumbnail

    • diff --git a/docs/index.html b/docs/index.html index c92d6c9..2d8ab51 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1005,9 +1005,9 @@

      Installation

      any of the parameters defined on IBaseOptions. For example, to prevent EasyImage from auto-orientating your image, you can pass autoOrient: false on any command.

      Every command must have a src parameter. If you do not specify a dst, then a random file will be created. Be sure to clean up randomly created files by - either moving them to permanent storage, or deleting them. Some command have other required options.

      -

      The examples below only specify the required arguments. See the Docs for all available options for each - command.

      + either moving them to permanent storage, or deleting them. Some commands have other required options.

      +

      The examples below only specify some of the available arguments. See the Docs for all available options for + each command.

      Convert

      The convert() command can convert an image file from one type to another.

      import {convert} from "easyimage";
      @@ -1092,7 +1092,7 @@ 

      Info

      ImageMagick.

      import {getImageMagickVersion} from "easyimage";
       
      -const version = getImageMagickVersion();
      +const version = await getImageMagickVersion();
       

      Error Handling

      There are 5 different types of errors that can be thrown.

        @@ -1192,7 +1192,7 @@

        convert

      • @@ -1220,7 +1220,7 @@

        crop

      • @@ -1248,7 +1248,7 @@

        execute

      • @@ -1282,7 +1282,7 @@

        getImageMagickVersion

      • @@ -1313,7 +1313,7 @@

        info

      • @@ -1344,7 +1344,7 @@

        rescrop

      • @@ -1372,7 +1372,7 @@

        resize

      • @@ -1400,7 +1400,7 @@

        rotate

      • @@ -1428,7 +1428,7 @@

        thumbnail

      • diff --git a/docs/interfaces/ibaseoptions.html b/docs/interfaces/ibaseoptions.html index b383983..dcd7379 100644 --- a/docs/interfaces/ibaseoptions.html +++ b/docs/interfaces/ibaseoptions.html @@ -1058,7 +1058,7 @@

        Optional autoOrient

        autoOrient: boolean
        @@ -1078,7 +1078,7 @@

        Optional background

        background: string
        @@ -1093,7 +1093,7 @@

        Optional coalesce

        coalesce: boolean
        @@ -1116,7 +1116,7 @@

        Optional dst

        dst: string
        @@ -1136,7 +1136,7 @@

        Optional flatten

        flatten: boolean
        @@ -1156,7 +1156,7 @@

        Optional quality

        quality: number
        @@ -1176,7 +1176,7 @@

        src

        src: string
        diff --git a/docs/interfaces/iconvertoptions.html b/docs/interfaces/iconvertoptions.html index 32946c3..dc4649e 100644 --- a/docs/interfaces/iconvertoptions.html +++ b/docs/interfaces/iconvertoptions.html @@ -1047,7 +1047,7 @@

        Optional autoOrient

        @@ -1068,7 +1068,7 @@

        Optional background

        @@ -1084,7 +1084,7 @@

        Optional coalesce

        @@ -1108,7 +1108,7 @@

        Optional dst

        @@ -1129,7 +1129,7 @@

        Optional flatten

        @@ -1150,7 +1150,7 @@

        Optional quality

        @@ -1171,7 +1171,7 @@

        src

        diff --git a/docs/interfaces/icropoptions.html b/docs/interfaces/icropoptions.html index 8f99ace..3989c17 100644 --- a/docs/interfaces/icropoptions.html +++ b/docs/interfaces/icropoptions.html @@ -1080,7 +1080,7 @@

        Optional autoOrient

        @@ -1101,7 +1101,7 @@

        Optional background

        @@ -1117,7 +1117,7 @@

        Optional coalesce

        @@ -1140,7 +1140,7 @@

        Optional cropHeight

        cropHeight: number
        @@ -1160,7 +1160,7 @@

        cropWidth

        cropWidth: number
        @@ -1175,7 +1175,7 @@

        Optional cropheight

        cropheight: number
        @@ -1194,7 +1194,7 @@

        Optional cropwidth

        cropwidth: number
        @@ -1214,7 +1214,7 @@

        Optional dst

        @@ -1235,7 +1235,7 @@

        Optional flatten

        @@ -1255,7 +1255,7 @@

        Optional gravity

        gravity: string
        @@ -1276,7 +1276,7 @@

        Optional quality

        @@ -1297,7 +1297,7 @@

        src

        @@ -1312,7 +1312,7 @@

        Optional x

        x: number
        @@ -1332,7 +1332,7 @@

        Optional y

        y: number
        diff --git a/docs/interfaces/idensity.html b/docs/interfaces/idensity.html index 80c49d6..42fced6 100644 --- a/docs/interfaces/idensity.html +++ b/docs/interfaces/idensity.html @@ -1021,7 +1021,7 @@

        x

        x: number
        @@ -1031,7 +1031,7 @@

        y

        y: number
        diff --git a/docs/interfaces/iimagemagickcommandresult.html b/docs/interfaces/iimagemagickcommandresult.html index e9e1b5b..bae5510 100644 --- a/docs/interfaces/iimagemagickcommandresult.html +++ b/docs/interfaces/iimagemagickcommandresult.html @@ -1021,7 +1021,7 @@

        stderr

        stderr: string
        @@ -1031,7 +1031,7 @@

        stdout

        stdout: string
        diff --git a/docs/interfaces/iinforesult.html b/docs/interfaces/iinforesult.html index a25df29..9286a37 100644 --- a/docs/interfaces/iinforesult.html +++ b/docs/interfaces/iinforesult.html @@ -1053,7 +1053,7 @@

        density

        density: IDensity
        @@ -1068,7 +1068,7 @@

        depth

        depth: number
        @@ -1083,7 +1083,7 @@

        height

        height: number
        @@ -1098,7 +1098,7 @@

        name

        name: string
        @@ -1113,7 +1113,7 @@

        orientation

        orientation: string
        @@ -1128,7 +1128,7 @@

        path

        path: string
        @@ -1143,7 +1143,7 @@

        size

        size: number
        @@ -1158,7 +1158,7 @@

        type

        type: string
        @@ -1173,7 +1173,7 @@

        Optional warnings

        warnings: string
        @@ -1188,7 +1188,7 @@

        width

        width: number
        diff --git a/docs/interfaces/irescropoptions.html b/docs/interfaces/irescropoptions.html index c1746d0..b27ead1 100644 --- a/docs/interfaces/irescropoptions.html +++ b/docs/interfaces/irescropoptions.html @@ -1095,7 +1095,7 @@

        Optional autoOrient

        Inherited from IBaseOptions.autoOrient

        Overrides IBaseOptions.autoOrient

        @@ -1117,7 +1117,7 @@

        Optional background

        Inherited from IBaseOptions.background

        Overrides IBaseOptions.background

        @@ -1134,7 +1134,7 @@

        Optional coalesce

        Inherited from IBaseOptions.coalesce

        Overrides IBaseOptions.coalesce

        @@ -1158,7 +1158,7 @@

        Optional cropHeight

        @@ -1179,7 +1179,7 @@

        cropWidth

        @@ -1195,7 +1195,7 @@

        Optional cropheight

        @@ -1215,7 +1215,7 @@

        Optional cropwidth

        @@ -1236,7 +1236,7 @@

        Optional dst

        Inherited from IBaseOptions.dst

        Overrides IBaseOptions.dst

        @@ -1258,7 +1258,7 @@

        Optional flatten

        Inherited from IBaseOptions.flatten

        Overrides IBaseOptions.flatten

        @@ -1279,7 +1279,7 @@

        Optional gravity

        @@ -1300,7 +1300,7 @@

        Optional height

        @@ -1321,7 +1321,7 @@

        Optional ignoreAspect

        Inherited from IResizeOptions.ignoreAspectRatio

        @@ -1342,7 +1342,7 @@

        Optional onlyDownscale

        Inherited from IResizeOptions.onlyDownscale

        @@ -1364,7 +1364,7 @@

        Optional quality

        Inherited from IBaseOptions.quality

        Overrides IBaseOptions.quality

        @@ -1386,7 +1386,7 @@

        src

        Inherited from IBaseOptions.src

        Overrides IBaseOptions.src

        @@ -1402,7 +1402,7 @@

        width

        @@ -1418,7 +1418,7 @@

        Optional x

        @@ -1439,7 +1439,7 @@

        Optional y

        diff --git a/docs/interfaces/iresizeoptions.html b/docs/interfaces/iresizeoptions.html index d835f7f..f972610 100644 --- a/docs/interfaces/iresizeoptions.html +++ b/docs/interfaces/iresizeoptions.html @@ -1068,7 +1068,7 @@

        Optional autoOrient

        @@ -1089,7 +1089,7 @@

        Optional background

        @@ -1105,7 +1105,7 @@

        Optional coalesce

        @@ -1129,7 +1129,7 @@

        Optional dst

        @@ -1150,7 +1150,7 @@

        Optional flatten

        @@ -1170,7 +1170,7 @@

        Optional height

        height: number
        @@ -1190,7 +1190,7 @@

        Optional ignoreAspectignoreAspectRatio: boolean

        @@ -1210,7 +1210,7 @@

        Optional onlyDownscaleonlyDownscale: boolean

        @@ -1231,7 +1231,7 @@

        Optional quality

        @@ -1252,7 +1252,7 @@

        src

        @@ -1267,7 +1267,7 @@

        width

        width: number
        diff --git a/docs/interfaces/irotateoptions.html b/docs/interfaces/irotateoptions.html index d6cf739..5f4a049 100644 --- a/docs/interfaces/irotateoptions.html +++ b/docs/interfaces/irotateoptions.html @@ -1051,7 +1051,7 @@

        Optional autoOrient

        @@ -1072,7 +1072,7 @@

        Optional background

        @@ -1088,7 +1088,7 @@

        Optional coalesce

        @@ -1111,7 +1111,7 @@

        degree

        degree: number
        @@ -1127,7 +1127,7 @@

        Optional dst

        @@ -1148,7 +1148,7 @@

        Optional flatten

        @@ -1169,7 +1169,7 @@

        Optional quality

        @@ -1190,7 +1190,7 @@

        src

        diff --git a/docs/interfaces/ithumbnailoptions.html b/docs/interfaces/ithumbnailoptions.html index 1c26a4f..27073b6 100644 --- a/docs/interfaces/ithumbnailoptions.html +++ b/docs/interfaces/ithumbnailoptions.html @@ -1071,7 +1071,7 @@

        Optional autoOrient

        @@ -1092,7 +1092,7 @@

        Optional background

        @@ -1108,7 +1108,7 @@

        Optional coalesce

        @@ -1132,7 +1132,7 @@

        Optional dst

        @@ -1153,7 +1153,7 @@

        Optional flatten

        @@ -1173,7 +1173,7 @@

        Optional gravity

        gravity: string
        @@ -1193,7 +1193,7 @@

        height

        height: number
        @@ -1208,7 +1208,7 @@

        Optional interpolate

        interpolate: string
        @@ -1224,7 +1224,7 @@

        Optional quality

        @@ -1245,7 +1245,7 @@

        src

        @@ -1260,7 +1260,7 @@

        width

        width: number
        @@ -1275,7 +1275,7 @@

        Optional x

        x: number
        @@ -1290,7 +1290,7 @@

        Optional y

        y: number
        diff --git a/lib/EasyImage.js b/lib/EasyImage.js deleted file mode 100644 index d309528..0000000 --- a/lib/EasyImage.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -/* - EasyImage - - EasyImage is a promise-based image processing module - for Node.js, it is built on top of ImageMagick, so - make sure ImageMagick is installed on your system. - - Copyright (c) 2015 Hage Yaapa - Maintained by Kevin Gravier - - MIT License - */ -exports.__esModule = true; -var tslib_1 = require("tslib"); -tslib_1.__exportStar(require("./ImageMagick"), exports); -tslib_1.__exportStar(require("./Commands/info"), exports); -tslib_1.__exportStar(require("./Commands/crop"), exports); -tslib_1.__exportStar(require("./Commands/convert"), exports); -tslib_1.__exportStar(require("./Commands/resize"), exports); -tslib_1.__exportStar(require("./Commands/rotate"), exports); -tslib_1.__exportStar(require("./Commands/rescrop"), exports); -tslib_1.__exportStar(require("./Commands/thumbnail"), exports); -tslib_1.__exportStar(require("./Errors/BadDestinationError"), exports); -tslib_1.__exportStar(require("./Errors/ImageMagickMissingError"), exports); -tslib_1.__exportStar(require("./Errors/MissingExtensionError"), exports); -tslib_1.__exportStar(require("./Errors/MissingOptionsError"), exports); -tslib_1.__exportStar(require("./Errors/UnsupportedError"), exports); diff --git a/lib/Commands/convert.js b/lib/commands/convert.js similarity index 73% rename from lib/Commands/convert.js rename to lib/commands/convert.js index 5145da3..585370c 100644 --- a/lib/Commands/convert.js +++ b/lib/commands/convert.js @@ -14,8 +14,8 @@ var tslib_1 = require("tslib"); MIT License */ var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,15 +30,15 @@ function convert(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.applyDefaultsToBaseOptions(options); - Utilities_1.checkForMissingOptions(options, ["src"]); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + utilities_1.applyDefaultsToBaseOptions(options); + utilities_1.checkForMissingOptions(options, ["src"]); + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 1: _a.sent(); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); + utilities_1.applyBaseOptionsToArgs(options, args); args.push(options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 2: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; diff --git a/lib/Commands/crop.js b/lib/commands/crop.js similarity index 74% rename from lib/Commands/crop.js rename to lib/commands/crop.js index 5cc13f7..1047a1d 100644 --- a/lib/Commands/crop.js +++ b/lib/commands/crop.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,21 +30,25 @@ function crop(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.applyDefaultsToBaseOptions(options); + utilities_1.applyDefaultsToBaseOptions(options); upgradeCropOptions(options); applyDefaultsToCropOptions(options); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 1: _a.sent(); - Utilities_1.checkForMissingOptions(options, ["src", "cropWidth"]); + utilities_1.checkForMissingOptions(options, ["src", "cropWidth"]); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); - cropDefinition = options.cropWidth + "x" + options.cropHeight + "+" + options.x + "+" + options.y; + utilities_1.applyBaseOptionsToArgs(options, args); + cropDefinition = "" + options.cropWidth; + if (options.cropHeight) { + cropDefinition += "x" + options.cropHeight; + } + cropDefinition += "+" + options.x + "+" + options.y; if (options.gravity) { args.push("-gravity", options.gravity); } args.push("-crop", cropDefinition, options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 2: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; diff --git a/lib/Commands/info.js b/lib/commands/info.js similarity index 93% rename from lib/Commands/info.js rename to lib/commands/info.js index 0a738fd..b8105d0 100644 --- a/lib/Commands/info.js +++ b/lib/commands/info.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var ImageMagick_1 = require("../ImageMagick"); -var UnsupportedError_1 = require("../Errors/UnsupportedError"); +var execute_1 = require("../execute"); +var UnsupportedError_1 = require("../errors/UnsupportedError"); Promise = Promise || Bluebird; /** * Returns information about an image. @@ -30,7 +30,7 @@ function info(filePath) { switch (_b.label) { case 0: args = ["-format", "%m %z %w %h %b %x %y %[orientation] %f", filePath]; - return [4 /*yield*/, ImageMagick_1.execute("identify", args)]; + return [4 /*yield*/, execute_1.execute("identify", args)]; case 1: _a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr; if (stdout === "") { diff --git a/lib/Commands/rescrop.js b/lib/commands/rescrop.js similarity index 80% rename from lib/Commands/rescrop.js rename to lib/commands/rescrop.js index b10501b..c27480d 100644 --- a/lib/Commands/rescrop.js +++ b/lib/commands/rescrop.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,14 +30,14 @@ function rescrop(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.applyDefaultsToBaseOptions(options); + utilities_1.applyDefaultsToBaseOptions(options); upgradeCropOptions(options); applyDefaultsToRescropOptions(options); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 1: _a.sent(); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); + utilities_1.applyBaseOptionsToArgs(options, args); resizeDefinition = "" + options.width; if (options.height) { resizeDefinition += "x" + options.height; @@ -52,12 +52,16 @@ function rescrop(options) { resizeDefinition += ">"; } } - cropDefinition = options.cropWidth + "x" + options.cropHeight + "+" + options.x + "+" + options.y; + cropDefinition = "" + options.cropWidth; + if (options.cropHeight) { + cropDefinition += "x" + options.cropHeight; + } + cropDefinition += "+" + options.x + "+" + options.y; if (options.gravity) { args.push("-gravity", options.gravity); } args.push("-resize", resizeDefinition, "-crop", cropDefinition, options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 2: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; diff --git a/lib/Commands/resize.js b/lib/commands/resize.js similarity index 83% rename from lib/Commands/resize.js rename to lib/commands/resize.js index c865e01..d764504 100644 --- a/lib/Commands/resize.js +++ b/lib/commands/resize.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,14 +30,14 @@ function resize(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.checkForMissingOptions(options, ["src", "width"]); - Utilities_1.applyDefaultsToBaseOptions(options); + utilities_1.checkForMissingOptions(options, ["src", "width"]); + utilities_1.applyDefaultsToBaseOptions(options); applyDefaultsToResizeOptions(options); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 1: _a.sent(); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); + utilities_1.applyBaseOptionsToArgs(options, args); resizeDefinition = "" + options.width; if (options.height) { resizeDefinition += "x" + options.height; @@ -53,7 +53,7 @@ function resize(options) { } } args.push("-resize", resizeDefinition, options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 2: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; diff --git a/lib/Commands/rotate.js b/lib/commands/rotate.js similarity index 74% rename from lib/Commands/rotate.js rename to lib/commands/rotate.js index f10337c..909bda2 100644 --- a/lib/Commands/rotate.js +++ b/lib/commands/rotate.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,15 +30,15 @@ function rotate(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.checkForMissingOptions(options, ["src", "degree"]); - Utilities_1.applyDefaultsToBaseOptions(options); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + utilities_1.checkForMissingOptions(options, ["src", "degree"]); + utilities_1.applyDefaultsToBaseOptions(options); + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 1: _a.sent(); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); + utilities_1.applyBaseOptionsToArgs(options, args); args.push("-rotate", options.degree.toString(), options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 2: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; diff --git a/lib/Commands/thumbnail.js b/lib/commands/thumbnail.js similarity index 86% rename from lib/Commands/thumbnail.js rename to lib/commands/thumbnail.js index 3dfadcb..3144e3a 100644 --- a/lib/Commands/thumbnail.js +++ b/lib/commands/thumbnail.js @@ -14,8 +14,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); -var Utilities_1 = require("../Utilities"); -var ImageMagick_1 = require("../ImageMagick"); +var utilities_1 = require("../utilities"); +var execute_1 = require("../execute"); var info_1 = require("./info"); Promise = Promise || Bluebird; /** @@ -30,19 +30,19 @@ function thumbnail(options) { return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: - Utilities_1.applyDefaultsToBaseOptions(options); + utilities_1.applyDefaultsToBaseOptions(options); return [4 /*yield*/, applyDefaultsToThumbnailOptions(options)]; case 1: _a.sent(); - Utilities_1.checkForMissingOptions(options, ["src", "width", "height"]); - return [4 /*yield*/, Utilities_1.ensureDestinationDirectoryExists(options)]; + utilities_1.checkForMissingOptions(options, ["src", "width", "height"]); + return [4 /*yield*/, utilities_1.ensureDestinationDirectoryExists(options)]; case 2: _a.sent(); return [4 /*yield*/, info_1.info(options.src)]; case 3: infoData = _a.sent(); args = [options.src]; - Utilities_1.applyBaseOptionsToArgs(options, args); + utilities_1.applyBaseOptionsToArgs(options, args); if (options.gravity) { args.push("-gravity", options.gravity); } @@ -56,7 +56,7 @@ function thumbnail(options) { } args.push("-crop", options.width + "x" + options.height + "+" + options.x + "+" + options.y); args.push(options.dst); - return [4 /*yield*/, ImageMagick_1.execute("convert", args)]; + return [4 /*yield*/, execute_1.execute("convert", args)]; case 4: _a.sent(); return [2 /*return*/, info_1.info(options.dst)]; @@ -78,7 +78,7 @@ function applyDefaultsToThumbnailOptions(options) { options.y = 0; } if (!!options.interpolate) return [3 /*break*/, 2]; - return [4 /*yield*/, ImageMagick_1.getImageMagickVersion()]; + return [4 /*yield*/, execute_1.getImageMagickVersion()]; case 1: availableVersion = _a.sent(); switch (availableVersion) { diff --git a/lib/easyimage.js b/lib/easyimage.js new file mode 100644 index 0000000..a045c16 --- /dev/null +++ b/lib/easyimage.js @@ -0,0 +1,28 @@ +"use strict"; +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ +exports.__esModule = true; +var tslib_1 = require("tslib"); +tslib_1.__exportStar(require("./execute"), exports); +tslib_1.__exportStar(require("./commands/info"), exports); +tslib_1.__exportStar(require("./commands/crop"), exports); +tslib_1.__exportStar(require("./commands/convert"), exports); +tslib_1.__exportStar(require("./commands/resize"), exports); +tslib_1.__exportStar(require("./commands/rotate"), exports); +tslib_1.__exportStar(require("./commands/rescrop"), exports); +tslib_1.__exportStar(require("./commands/thumbnail"), exports); +tslib_1.__exportStar(require("./errors/BadDestinationError"), exports); +tslib_1.__exportStar(require("./errors/ImageMagickMissingError"), exports); +tslib_1.__exportStar(require("./errors/MissingExtensionError"), exports); +tslib_1.__exportStar(require("./errors/MissingOptionsError"), exports); +tslib_1.__exportStar(require("./errors/UnsupportedError"), exports); diff --git a/lib/Errors/BadDestinationError.js b/lib/errors/BadDestinationError.js similarity index 100% rename from lib/Errors/BadDestinationError.js rename to lib/errors/BadDestinationError.js diff --git a/lib/Errors/ImageMagickMissingError.js b/lib/errors/ImageMagickMissingError.js similarity index 100% rename from lib/Errors/ImageMagickMissingError.js rename to lib/errors/ImageMagickMissingError.js diff --git a/lib/Errors/MissingExtensionError.js b/lib/errors/MissingExtensionError.js similarity index 100% rename from lib/Errors/MissingExtensionError.js rename to lib/errors/MissingExtensionError.js diff --git a/lib/Errors/MissingOptionsError.js b/lib/errors/MissingOptionsError.js similarity index 100% rename from lib/Errors/MissingOptionsError.js rename to lib/errors/MissingOptionsError.js diff --git a/lib/Errors/UnsupportedError.js b/lib/errors/UnsupportedError.js similarity index 100% rename from lib/Errors/UnsupportedError.js rename to lib/errors/UnsupportedError.js diff --git a/lib/ImageMagick.js b/lib/execute.js similarity index 97% rename from lib/ImageMagick.js rename to lib/execute.js index e669c87..2f0b2bb 100644 --- a/lib/ImageMagick.js +++ b/lib/execute.js @@ -15,8 +15,8 @@ exports.__esModule = true; var tslib_1 = require("tslib"); var Bluebird = require("bluebird"); var child_process_1 = require("child_process"); -var ImageMagickMissingError_1 = require("./Errors/ImageMagickMissingError"); -var UnsupportedError_1 = require("./Errors/UnsupportedError"); +var ImageMagickMissingError_1 = require("./errors/ImageMagickMissingError"); +var UnsupportedError_1 = require("./errors/UnsupportedError"); Promise = Promise || Bluebird; var availableImageMagickVersion = null; /** diff --git a/lib/Options.js b/lib/options.js similarity index 100% rename from lib/Options.js rename to lib/options.js diff --git a/lib/Utilities.js b/lib/utilities.js similarity index 94% rename from lib/Utilities.js rename to lib/utilities.js index 409198b..02180eb 100644 --- a/lib/Utilities.js +++ b/lib/utilities.js @@ -18,9 +18,9 @@ var mkdirp = require("mkdirp"); var os_1 = require("os"); var path_1 = require("path"); var shortid_1 = require("shortid"); -var BadDestinationError_1 = require("./Errors/BadDestinationError"); -var MissingOptionsError_1 = require("./Errors/MissingOptionsError"); -var MissingExtensionError_1 = require("./Errors/MissingExtensionError"); +var BadDestinationError_1 = require("./errors/BadDestinationError"); +var MissingOptionsError_1 = require("./errors/MissingOptionsError"); +var MissingExtensionError_1 = require("./errors/MissingExtensionError"); Promise = Promise || Bluebird; function ensureDestinationDirectoryExists(options) { if (!options.dst) { diff --git a/package-lock.json b/package-lock.json index 4e6ae97..416cd97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,27 @@ "integrity": "sha512-2nHw8pBp6J0N4mHPEO5GJptmd0KKjLFz/wpBiLMOT8UVnGqAP2e7P44wKVj+ujPvsFuIGyB2waDA3dpYX3c6Aw==", "dev": true }, + "@types/chai": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.0.tgz", + "integrity": "sha512-OuYBlXWHYthxIudMXMeQr92f6D97YoT9CUYCRb0BEP4OavC95jNcczjjr4Ob3H5E1IqlWqwj+leUZPSeth27Qw==", + "dev": true + }, + "@types/chai-as-promised": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.0.tgz", + "integrity": "sha512-MFiW54UOSt+f2bRw8J7LgQeIvE/9b4oGvwU7XW30S9QGAiHGnU/fmiOprsyMkdmH2rl8xSPc0/yrQw8juXU6bQ==", + "dev": true, + "requires": { + "@types/chai": "4.1.0" + } + }, + "@types/events": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-1.1.0.tgz", + "integrity": "sha512-y3bR98mzYOo0pAZuiLari+cQyiKk3UXRuT45h1RjhfeCzqkjaVsfZJNaxdgtk7/3tzOm1ozLTqEqMP3VbI48jw==", + "dev": true + }, "@types/fs-extra": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-4.0.0.tgz", @@ -19,6 +40,17 @@ "@types/node": "4.2.23" } }, + "@types/glob": { + "version": "5.0.34", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-5.0.34.tgz", + "integrity": "sha512-sUvpieq+HsWTLdkeOI8Mi8u22Ag3AoGuM3sv+XMP1bKtbaIAHpEA2f52K2mz6vK5PVhTa3bFyRZLZMqTxOo2Cw==", + "dev": true, + "requires": { + "@types/events": "1.1.0", + "@types/minimatch": "2.0.29", + "@types/node": "4.2.23" + } + }, "@types/handlebars": { "version": "4.0.31", "resolved": "https://registry.npmjs.org/@types/handlebars/-/handlebars-4.0.31.tgz", @@ -58,12 +90,28 @@ "@types/node": "4.2.23" } }, + "@types/mocha": { + "version": "2.2.46", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.46.tgz", + "integrity": "sha512-fwTTP5QLf4xHMkv7ovcKvmlLWX3GrxCa5DRQDOilVyYGCp+arZTAQJCy7/4GKezzYJjfWMpB/Cy4e8nrc9XioA==", + "dev": true + }, "@types/node": { "version": "4.2.23", "resolved": "https://registry.npmjs.org/@types/node/-/node-4.2.23.tgz", "integrity": "sha512-U6IchCNLRyswc9p6G6lxWlbE+KwAhZp6mGo6MD2yWpmFomhYmetK+c98OpKyvphNn04CU3aXeJrXdOqbXVTS/w==", "dev": true }, + "@types/rimraf": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-2.0.2.tgz", + "integrity": "sha512-Hm/bnWq0TCy7jmjeN5bKYij9vw5GrDFWME4IuxV08278NtU/VdGbzsBohcCUJ7+QMqmUq5hpRKB39HeQWJjztQ==", + "dev": true, + "requires": { + "@types/glob": "5.0.34", + "@types/node": "4.2.23" + } + }, "@types/shelljs": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.0.tgz", @@ -79,6 +127,34 @@ "integrity": "sha1-gJPuBBam4r8qpjOBCRFLP7/6Dps=", "dev": true }, + "@types/sinon": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-4.1.3.tgz", + "integrity": "sha512-Xxn32Q3mAJHOMU20bxcT6HiPksUJEkZA+nyZS4NhLo8kKb8hLhkBgp5OeW/BI3+9QmdrvDRk3caYNqtYb+TEbA==", + "dev": true + }, + "@types/sinon-chai": { + "version": "2.7.29", + "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-2.7.29.tgz", + "integrity": "sha512-EkI/ZvJT4hglWo7Ipf9SX+J+R9htNOMjW8xiOhce7+0csqvgoF5IXqY5Ae1GqRgNtWCuaywR5HjVa1snkTqpOw==", + "dev": true, + "requires": { + "@types/chai": "4.1.0", + "@types/sinon": "4.1.3" + } + }, + "@types/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=", + "dev": true + }, + "@types/strip-json-comments": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz", + "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==", + "dev": true + }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -96,6 +172,21 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -176,6 +267,17 @@ "check-error": "1.0.2" } }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.4.0" + } + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -203,6 +305,21 @@ } } }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, "commander": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", @@ -252,6 +369,15 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "formatio": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", + "integrity": "sha1-87IWfZBoxGmKjVH092CjmlTYGOs=", + "dev": true, + "requires": { + "samsam": "1.3.0" + } + }, "fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", @@ -331,6 +457,15 @@ "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", "dev": true }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "dev": true, + "requires": { + "parse-passwd": "1.0.0" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -359,6 +494,12 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -368,6 +509,12 @@ "graceful-fs": "4.1.11" } }, + "just-extend": { + "version": "1.1.27", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", + "dev": true + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -390,12 +537,30 @@ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, + "lolex": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.1.tgz", + "integrity": "sha512-mQuW55GhduF3ppo+ZRUTz1PRjEh1hS5BbqU7d8D0ez2OKxHDod7StPPeAVKisZR5aLkHZjdGWSL42LSONUJsZw==", + "dev": true + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", "dev": true }, + "make-error": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.2.tgz", + "integrity": "sha512-l9ra35l5VWLF24y75Tg8XgfGLX0ueRhph118WKM6H5denx4bB5QF59+4UAm9oJ2qsPQZas/CQUDdtDdfvYHBdQ==", + "dev": true + }, "marked": { "version": "0.3.12", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz", @@ -448,6 +613,27 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "nise": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.0.tgz", + "integrity": "sha512-q9jXh3UNsMV28KeqI43ILz5+c3l+RiNW8mhurEwCKckuHQbL+hTJIKKTiUlCPKlgQ/OukFvSnKB/Jk3+sFbkGA==", + "dev": true, + "requires": { + "formatio": "1.2.0", + "just-extend": "1.1.27", + "lolex": "1.6.0", + "path-to-regexp": "1.7.0", + "text-encoding": "0.6.4" + }, + "dependencies": { + "lolex": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", + "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", + "dev": true + } + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -467,6 +653,12 @@ "wordwrap": "0.0.3" } }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -479,6 +671,15 @@ "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "dev": true, + "requires": { + "isarray": "0.0.1" + } + }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", @@ -534,6 +735,12 @@ "glob": "7.1.2" } }, + "samsam": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", + "dev": true + }, "shelljs": { "version": "0.7.8", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", @@ -550,6 +757,38 @@ "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz", "integrity": "sha1-AzsRfWoul1gE9vCWnb59PQs1UTE=" }, + "sinon": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.1.6.tgz", + "integrity": "sha1-nLNGvdsYDWioBEKf/hSXjX+v1ik=", + "dev": true, + "requires": { + "diff": "3.3.1", + "formatio": "1.2.0", + "lodash.get": "4.4.2", + "lolex": "2.3.1", + "nise": "1.2.0", + "supports-color": "5.1.0", + "type-detect": "4.0.6" + }, + "dependencies": { + "supports-color": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz", + "integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "sinon-chai": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", + "dev": true + }, "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", @@ -559,6 +798,35 @@ "amdefine": "1.0.1" } }, + "source-map-support": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.1.tgz", + "integrity": "sha512-EZNecLNrsdRk9fcdOcjjy+Z/id7cr68sdmsYtR1gA45oQ81Ccea0UvM7DdSRblO0Ie5zWX31bvJTC7Y3QZVujg==", + "dev": true, + "requires": { + "source-map": "0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "supports-color": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", @@ -568,6 +836,50 @@ "has-flag": "2.0.0" } }, + "text-encoding": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", + "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", + "dev": true + }, + "ts-node": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-4.1.0.tgz", + "integrity": "sha512-xcZH12oVg9PShKhy3UHyDmuDLV3y7iKwX25aMVPt1SIXSuAfWkFiGPEkg+th8R4YKW/QCxDoW7lJdb15lx6QWg==", + "dev": true, + "requires": { + "arrify": "1.0.1", + "chalk": "2.3.0", + "diff": "3.3.1", + "make-error": "1.3.2", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "source-map-support": "0.5.1", + "tsconfig": "7.0.0", + "v8flags": "3.0.1", + "yn": "2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, + "tsconfig": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz", + "integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==", + "dev": true, + "requires": { + "@types/strip-bom": "3.0.0", + "@types/strip-json-comments": "0.0.30", + "strip-bom": "3.0.0", + "strip-json-comments": "2.0.1" + } + }, "tslib": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.8.1.tgz", @@ -657,6 +969,15 @@ "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc=", "dev": true }, + "v8flags": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.0.1.tgz", + "integrity": "sha1-3Oj8N5wX2fLJ6e142JzgAFKxt2s=", + "dev": true, + "requires": { + "homedir-polyfill": "1.0.1" + } + }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", @@ -688,6 +1009,12 @@ "decamelize": "1.2.0", "window-size": "0.1.0" } + }, + "yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", + "dev": true } } } diff --git a/package.json b/package.json index dc0d093..a29182e 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "3.0.0", "description": "A promise-based, user-friendly module for processing images in Node.js", "license": "MIT", - "main": "lib/EasyImage.js", - "types": "types/EasyImage.d.ts", + "main": "lib/easyimage.js", + "types": "types/easyimage.d.ts", "scripts": { - "test": "cd test && mocha", + "test": "mocha -r ts-node/register --timeout 5000 test/specs/*spec.ts", "build": "npm run src && npm run doc", - "doc": "typedoc src/ImageMagick.ts src/Options.ts src/Commands/* src/Errors/*", + "doc": "typedoc src/execute.ts src/options.ts src/commands/* src/errors/*", "src": "tsc" }, "author": { @@ -46,13 +46,22 @@ }, "devDependencies": { "@types/bluebird": "^3.5.19", + "@types/chai": "^4.1.0", + "@types/chai-as-promised": "^7.1.0", "@types/mkdirp": "^0.5.2", + "@types/mocha": "^2.2.46", "@types/node": "=4", + "@types/rimraf": "^2.0.2", "@types/shortid": "0.0.29", + "@types/sinon": "^4.1.3", + "@types/sinon-chai": "^2.7.29", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "mocha": "^4.1.0", - "rimraf": "^2.2.8", + "rimraf": "^2.6.2", + "sinon": "^4.1.6", + "sinon-chai": "^2.14.0", + "ts-node": "^4.1.0", "typedoc": "^0.9.0" } } diff --git a/src/EasyImage.ts b/src/EasyImage.ts deleted file mode 100644 index 3d349f3..0000000 --- a/src/EasyImage.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - EasyImage - - EasyImage is a promise-based image processing module - for Node.js, it is built on top of ImageMagick, so - make sure ImageMagick is installed on your system. - - Copyright (c) 2015 Hage Yaapa - Maintained by Kevin Gravier - - MIT License - */ - -export * from "./ImageMagick"; -export * from "./Commands/info"; -export * from "./Commands/crop"; -export * from "./Commands/convert"; -export * from "./Commands/resize"; -export * from "./Commands/rotate"; -export * from "./Commands/rescrop"; -export * from "./Commands/thumbnail"; - -export * from "./Errors/BadDestinationError"; -export * from "./Errors/ImageMagickMissingError"; -export * from "./Errors/MissingExtensionError"; -export * from "./Errors/MissingOptionsError"; -export * from "./Errors/UnsupportedError"; diff --git a/src/Commands/convert.ts b/src/commands/convert.ts similarity index 88% rename from src/Commands/convert.ts rename to src/commands/convert.ts index b76e6e6..3cec23c 100644 --- a/src/Commands/convert.ts +++ b/src/commands/convert.ts @@ -11,9 +11,9 @@ MIT License */ import * as Bluebird from "bluebird"; -import {IBaseOptions} from "../Options"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../Utilities"; -import {execute} from "../ImageMagick"; +import {IBaseOptions} from "../options"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../utilities"; +import {execute} from "../execute"; import {info, IInfoResult} from "./info"; Promise = Promise || Bluebird as any; diff --git a/src/Commands/crop.ts b/src/commands/crop.ts similarity index 88% rename from src/Commands/crop.ts rename to src/commands/crop.ts index 7166102..81f579a 100644 --- a/src/Commands/crop.ts +++ b/src/commands/crop.ts @@ -12,9 +12,9 @@ */ import * as Bluebird from "bluebird"; -import {IBaseOptions} from "../Options"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../Utilities"; -import {execute} from "../ImageMagick"; +import {IBaseOptions} from "../options"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../utilities"; +import {execute} from "../execute"; import {info, IInfoResult} from "./info"; Promise = Promise || Bluebird as any; @@ -38,7 +38,11 @@ export async function crop(options: ICropOptions): Promise { applyBaseOptionsToArgs(options, args); - const cropDefinition = options.cropWidth + "x" + options.cropHeight + "+" + options.x + "+" + options.y; + let cropDefinition = `${options.cropWidth}`; + if (options.cropHeight) { + cropDefinition += `x${options.cropHeight}`; + } + cropDefinition += `+${options.x}+${options.y}`; if (options.gravity) { args.push("-gravity", options.gravity); diff --git a/src/Commands/info.ts b/src/commands/info.ts similarity index 96% rename from src/Commands/info.ts rename to src/commands/info.ts index 63373ec..761192c 100644 --- a/src/Commands/info.ts +++ b/src/commands/info.ts @@ -12,8 +12,8 @@ */ import * as Bluebird from "bluebird"; -import {execute} from "../ImageMagick"; -import {UnsupportedError} from "../Errors/UnsupportedError"; +import {execute} from "../execute"; +import {UnsupportedError} from "../errors/UnsupportedError"; Promise = Promise || Bluebird as any; diff --git a/src/Commands/rescrop.ts b/src/commands/rescrop.ts similarity index 88% rename from src/Commands/rescrop.ts rename to src/commands/rescrop.ts index 1fe743e..30af872 100644 --- a/src/Commands/rescrop.ts +++ b/src/commands/rescrop.ts @@ -12,8 +12,8 @@ */ import * as Bluebird from "bluebird"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs} from "../Utilities"; -import {execute} from "../ImageMagick"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs} from "../utilities"; +import {execute} from "../execute"; import {info, IInfoResult} from "./info"; import {ICropOptions} from "./crop"; import {IResizeOptions} from "./resize"; @@ -51,7 +51,12 @@ export async function rescrop(options: IResCropOptions): Promise { } } - const cropDefinition = options.cropWidth + "x" + options.cropHeight + "+" + options.x + "+" + options.y; + let cropDefinition = `${options.cropWidth}`; + if (options.cropHeight) { + cropDefinition += `x${options.cropHeight}`; + } + cropDefinition += `+${options.x}+${options.y}`; + if (options.gravity) { args.push("-gravity", options.gravity); diff --git a/src/Commands/resize.ts b/src/commands/resize.ts similarity index 93% rename from src/Commands/resize.ts rename to src/commands/resize.ts index dbc833b..78f1c4a 100644 --- a/src/Commands/resize.ts +++ b/src/commands/resize.ts @@ -12,9 +12,9 @@ */ import * as Bluebird from "bluebird"; -import {IBaseOptions} from "../Options"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../Utilities"; -import {execute} from "../ImageMagick"; +import {IBaseOptions} from "../options"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../utilities"; +import {execute} from "../execute"; import {info, IInfoResult} from "./info"; Promise = Promise || Bluebird as any; diff --git a/src/Commands/rotate.ts b/src/commands/rotate.ts similarity index 89% rename from src/Commands/rotate.ts rename to src/commands/rotate.ts index fec41f2..f5c1529 100644 --- a/src/Commands/rotate.ts +++ b/src/commands/rotate.ts @@ -12,9 +12,9 @@ */ import * as Bluebird from "bluebird"; -import {IBaseOptions} from "../Options"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../Utilities"; -import {execute} from "../ImageMagick"; +import {IBaseOptions} from "../options"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../utilities"; +import {execute} from "../execute"; import {info, IInfoResult} from "./info"; Promise = Promise || Bluebird as any; diff --git a/src/Commands/thumbnail.ts b/src/commands/thumbnail.ts similarity index 93% rename from src/Commands/thumbnail.ts rename to src/commands/thumbnail.ts index 457a90e..fb67563 100644 --- a/src/Commands/thumbnail.ts +++ b/src/commands/thumbnail.ts @@ -12,9 +12,9 @@ */ import * as Bluebird from "bluebird"; -import {IBaseOptions} from "../Options"; -import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../Utilities"; -import {execute, getImageMagickVersion} from "../ImageMagick"; +import {IBaseOptions} from "../options"; +import {ensureDestinationDirectoryExists, applyDefaultsToBaseOptions, applyBaseOptionsToArgs, checkForMissingOptions} from "../utilities"; +import {execute, getImageMagickVersion} from "../execute"; import {info, IInfoResult} from "./info"; Promise = Promise || Bluebird as any; diff --git a/src/easyimage.ts b/src/easyimage.ts new file mode 100644 index 0000000..553e3a6 --- /dev/null +++ b/src/easyimage.ts @@ -0,0 +1,27 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +export * from "./execute"; +export * from "./commands/info"; +export * from "./commands/crop"; +export * from "./commands/convert"; +export * from "./commands/resize"; +export * from "./commands/rotate"; +export * from "./commands/rescrop"; +export * from "./commands/thumbnail"; + +export * from "./errors/BadDestinationError"; +export * from "./errors/ImageMagickMissingError"; +export * from "./errors/MissingExtensionError"; +export * from "./errors/MissingOptionsError"; +export * from "./errors/UnsupportedError"; diff --git a/src/Errors/BadDestinationError.ts b/src/errors/BadDestinationError.ts similarity index 100% rename from src/Errors/BadDestinationError.ts rename to src/errors/BadDestinationError.ts diff --git a/src/Errors/ImageMagickMissingError.ts b/src/errors/ImageMagickMissingError.ts similarity index 100% rename from src/Errors/ImageMagickMissingError.ts rename to src/errors/ImageMagickMissingError.ts diff --git a/src/Errors/MissingExtensionError.ts b/src/errors/MissingExtensionError.ts similarity index 100% rename from src/Errors/MissingExtensionError.ts rename to src/errors/MissingExtensionError.ts diff --git a/src/Errors/MissingOptionsError.ts b/src/errors/MissingOptionsError.ts similarity index 100% rename from src/Errors/MissingOptionsError.ts rename to src/errors/MissingOptionsError.ts diff --git a/src/Errors/UnsupportedError.ts b/src/errors/UnsupportedError.ts similarity index 100% rename from src/Errors/UnsupportedError.ts rename to src/errors/UnsupportedError.ts diff --git a/src/ImageMagick.ts b/src/execute.ts similarity index 95% rename from src/ImageMagick.ts rename to src/execute.ts index 9a82ee7..f58dbbf 100644 --- a/src/ImageMagick.ts +++ b/src/execute.ts @@ -13,8 +13,8 @@ import * as Bluebird from "bluebird"; import { execFile } from "child_process"; -import {ImageMagickMissingError} from "./Errors/ImageMagickMissingError"; -import {UnsupportedError} from "./Errors/UnsupportedError"; +import {ImageMagickMissingError} from "./errors/ImageMagickMissingError"; +import {UnsupportedError} from "./errors/UnsupportedError"; Promise = Promise || Bluebird as any; diff --git a/src/Options.ts b/src/options.ts similarity index 100% rename from src/Options.ts rename to src/options.ts diff --git a/src/Utilities.ts b/src/utilities.ts similarity index 92% rename from src/Utilities.ts rename to src/utilities.ts index a0f5138..73b6758 100644 --- a/src/Utilities.ts +++ b/src/utilities.ts @@ -17,10 +17,10 @@ import * as mkdirp from "mkdirp"; import {tmpdir} from "os"; import {dirname, extname} from "path"; import {generate} from "shortid"; -import {BadDestinationError} from "./Errors/BadDestinationError"; -import {IBaseOptions} from "./Options"; -import {MissingOptionsError} from "./Errors/MissingOptionsError"; -import {MissingExtensionError} from "./Errors/MissingExtensionError"; +import {BadDestinationError} from "./errors/BadDestinationError"; +import {IBaseOptions} from "./options"; +import {MissingOptionsError} from "./errors/MissingOptionsError"; +import {MissingExtensionError} from "./errors/MissingExtensionError"; Promise = Promise || Bluebird as any; diff --git a/test/files/tall.png b/test/files/tall.png new file mode 100644 index 0000000000000000000000000000000000000000..949171aec3cf73743c25d20ff1fd5ecfd9b34e14 GIT binary patch literal 3556 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 literal 0 HcmV?d00001 diff --git a/test/test.pdf b/test/files/test.pdf similarity index 100% rename from test/test.pdf rename to test/files/test.pdf diff --git a/test/files/wide.jpg b/test/files/wide.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3ed360e647369966d0b45b956d56b55c3d22d841 GIT binary patch literal 5577 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 literal 0 HcmV?d00001 diff --git a/test/files/wide.png b/test/files/wide.png new file mode 100644 index 0000000000000000000000000000000000000000..057e67f524390d36f3cb5153a3415f7cfaa8b32f GIT binary patch literal 3565 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 L)m0%VSwH + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir, unlink} from "fs"; + +import {convert} from "../../src/commands/convert"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("convert command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + describe("with image source", () => { + it("should convert to image", async () => { + const info = await convert({ + src: `${files}/wide.jpg`, + dst: `${output}/test.png`, + }); + + info.should.be.an("object"); + info.should.have.property("type"); + info.should.have.property("name"); + info.type.should.be.equal("png"); + info.name.should.be.equal("test.png"); + }); + + it("should convert to pdf", async () => { + const info = await convert({ + src: `${files}/wide.jpg`, + dst: `${output}/test.pdf`, + }); + + info.should.be.an("object"); + info.should.have.property("type"); + info.should.have.property("name"); + info.type.should.be.equal("pdf"); + info.name.should.be.equal("test.pdf"); + }); + }); + + describe("with pdf source", () => { + it("should convert one page to image", async () => { + const info = await convert({ + src: `${files}/test.pdf[1]`, + dst: `${output}/test.png`, + }); + + info.should.be.an("object"); + info.should.have.property("type"); + info.should.have.property("name"); + info.should.have.property("height"); + info.type.should.be.equal("png"); + info.name.should.be.equal("test.png"); + info.height.should.be.equal(792); + + }); + + it("should convert all pages to image", async () => { + const info = await convert({ + src: `${files}/test.pdf`, + dst: `${output}/test.png`, + }); + + info.should.be.an("object"); + info.should.have.property("type"); + info.should.have.property("name"); + info.should.have.property("height"); + info.type.should.be.equal("png"); + info.name.should.be.equal("test.png"); + info.height.should.be.equal(1584); + }); + }); + + describe("to temporary file", () => { + let fullPath: string = null; + afterEach((done: () => void) => { + if (fullPath) { + unlink(fullPath, done); + fullPath = null; + } + }); + + it("should create temporary dst file", async () => { + const info = await convert({ + src: `${files}/wide.jpg`, + }); + + fullPath = info.path; + + info.should.be.an("object"); + info.should.have.property("type"); + info.should.have.property("name"); + info.type.should.be.equal("jpeg"); + /EasyImage-.+\.jpg/.test(info.name).should.be.true; + }); + }); +}); diff --git a/test/specs/crop.spec.ts b/test/specs/crop.spec.ts new file mode 100644 index 0000000..81304da --- /dev/null +++ b/test/specs/crop.spec.ts @@ -0,0 +1,78 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir} from "fs"; + +import {crop} from "../../src/commands/crop"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("crop command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + describe("to square (only cropWidth)", () => { + it("should crop an image to smaller size", async () => { + const info = await crop({ + src: `${files}/wide.png`, + dst: `${output}/test.png`, + cropWidth: 50, + }); + + info.width.should.be.equal(50); + info.height.should.be.equal(50); + }); + + it("shouldn't crop to larger", async () => { + const info = await crop({ + src: `${files}/wide.png`, + dst: `${output}/test.png`, + cropWidth: 500, + }); + + info.width.should.be.equal(400); + info.height.should.be.equal(200); + }); + }); + + describe("to rectangle (both cropWidth and cropHeight)", () => { + it("should crop an image to smaller size", async () => { + const info = await crop({ + src: `${files}/wide.png`, + dst: `${output}/test.png`, + cropWidth: 50, + cropHeight: 75, + }); + + info.width.should.be.equal(50); + info.height.should.be.equal(75); + }); + }); +}); diff --git a/test/specs/easyimage.spec.ts b/test/specs/easyimage.spec.ts new file mode 100644 index 0000000..4ea002c --- /dev/null +++ b/test/specs/easyimage.spec.ts @@ -0,0 +1,65 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as EasyImage from "../../src/easyimage"; + +chai.use(chaiAsPromised); +chai.should(); + +describe("EasyImage Global", () => { + it("should be an object", () => { + EasyImage.should.be.an("object"); + }); + + it("should export helper functions", () => { + EasyImage.should.have.property("execute"); + EasyImage.should.have.property("getImageMagickVersion"); + + EasyImage.execute.should.be.a("function"); + EasyImage.getImageMagickVersion.should.be.a("function"); + }); + + it("should export commands", () => { + EasyImage.should.have.property("convert"); + EasyImage.should.have.property("crop"); + EasyImage.should.have.property("info"); + EasyImage.should.have.property("rescrop"); + EasyImage.should.have.property("resize"); + EasyImage.should.have.property("rotate"); + + EasyImage.convert.should.be.a("function"); + EasyImage.crop.should.be.a("function"); + EasyImage.info.should.be.a("function"); + EasyImage.rescrop.should.be.a("function"); + EasyImage.resize.should.be.a("function"); + EasyImage.rotate.should.be.a("function"); + + }); + + it("should export error constructors", () => { + EasyImage.should.have.property("BadDestinationError"); + EasyImage.should.have.property("ImageMagickMissingError"); + EasyImage.should.have.property("MissingExtensionError"); + EasyImage.should.have.property("MissingOptionsError"); + EasyImage.should.have.property("UnsupportedError"); + + EasyImage.BadDestinationError.should.be.a("function"); + EasyImage.ImageMagickMissingError.should.be.a("function"); + EasyImage.MissingExtensionError.should.be.a("function"); + EasyImage.MissingOptionsError.should.be.a("function"); + EasyImage.UnsupportedError.should.be.a("function"); + }); +}); diff --git a/test/specs/info.spec.ts b/test/specs/info.spec.ts new file mode 100644 index 0000000..e5d0510 --- /dev/null +++ b/test/specs/info.spec.ts @@ -0,0 +1,54 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; + +import {info} from "../../src/commands/info"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; + +describe("info command", () => { + + it("should return all fields", async () => { + const fileInfo = await info(`${files}/wide.png`); + + fileInfo.should.be.an("object"); + fileInfo.should.have.property("type"); + fileInfo.should.have.property("depth"); + fileInfo.should.have.property("width"); + fileInfo.should.have.property("height"); + fileInfo.should.have.property("size"); + fileInfo.should.have.property("density"); + fileInfo.should.have.property("orientation"); + fileInfo.should.have.property("name"); + fileInfo.should.have.property("path"); + fileInfo.density.should.have.property("x"); + fileInfo.density.should.have.property("y"); + + fileInfo.type.should.equal("png"); + fileInfo.depth.should.equal(8); + fileInfo.width.should.equal(400); + fileInfo.height.should.equal(200); + fileInfo.size.should.closeTo(3565, 10); + fileInfo.density.x.should.equal(28.35); + fileInfo.density.y.should.equal(28.35); + fileInfo.orientation.should.equal("Undefined"); + fileInfo.name.should.equal("wide.png"); + fileInfo.path.should.equal(`${files}/wide.png`); + }); +}); diff --git a/test/specs/rescrop.spec.ts b/test/specs/rescrop.spec.ts new file mode 100644 index 0000000..5dffe48 --- /dev/null +++ b/test/specs/rescrop.spec.ts @@ -0,0 +1,53 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir} from "fs"; + +import {rescrop} from "../../src/commands/rescrop"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("rescrop command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + it("should resize and crop an image", async () => { + const info = await rescrop({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 100, + height: 100, + cropWidth: 50, + }); + + info.width.should.equal(50); + info.height.should.equal(50); + }); +}); diff --git a/test/specs/resize.spec.ts b/test/specs/resize.spec.ts new file mode 100644 index 0000000..20b1435 --- /dev/null +++ b/test/specs/resize.spec.ts @@ -0,0 +1,224 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir} from "fs"; + +import {resize} from "../../src/commands/resize"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("resize command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + describe("with keeping aspect ratio", async () => { + describe("with only width", () => { + it("should make smaller image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 50, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 50, + }); + + wideInfo.width.should.equal(50); + wideInfo.height.should.equal(25); + + tallInfo.width.should.equal(50); + tallInfo.height.should.equal(100); + }); + + it("should make larger image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 500, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 500, + }); + + wideInfo.width.should.equal(500); + wideInfo.height.should.equal(250); + + tallInfo.width.should.equal(500); + tallInfo.height.should.equal(1000); + }); + }); + + describe("with width and height", () => { + it("should make smaller image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 100, + height: 100, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 100, + height: 100, + }); + + wideInfo.width.should.equal(100); + wideInfo.height.should.equal(50); + + tallInfo.width.should.equal(50); + tallInfo.height.should.equal(100); + }); + + it("should make larger image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 500, + height: 500, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 500, + height: 500, + }); + + wideInfo.width.should.equal(500); + wideInfo.height.should.equal(250); + + tallInfo.width.should.equal(250); + tallInfo.height.should.equal(500); + }); + }); + }); + + describe("without keeping aspect ratio", async () => { + describe("with width and height", () => { + it("should make smaller image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 100, + height: 100, + ignoreAspectRatio: true, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 100, + height: 100, + ignoreAspectRatio: true, + }); + + wideInfo.width.should.equal(100); + wideInfo.height.should.equal(100); + + tallInfo.width.should.equal(100); + tallInfo.height.should.equal(100); + }); + + it("should make larger image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 500, + height: 500, + ignoreAspectRatio: true, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 500, + height: 500, + ignoreAspectRatio: true, + }); + + wideInfo.width.should.equal(500); + wideInfo.height.should.equal(500); + + tallInfo.width.should.equal(500); + tallInfo.height.should.equal(500); + }); + }); + }); + + describe("with only downscaling", () => { + it("should make a smaller image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 50, + height: 50, + onlyDownscale: true, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 50, + height: 50, + onlyDownscale: true, + }); + + wideInfo.width.should.equal(50); + wideInfo.height.should.equal(25); + + tallInfo.width.should.equal(25); + tallInfo.height.should.equal(50); + }); + + it("shouldn't make larger image", async () => { + const wideInfo = await resize({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 500, + height: 500, + onlyDownscale: true, + }); + const tallInfo = await resize({ + src: `${files}/tall.png`, + dst: `${output}/tall.png`, + width: 500, + height: 500, + onlyDownscale: true, + }); + + wideInfo.width.should.equal(400); + wideInfo.height.should.equal(200); + + tallInfo.width.should.equal(200); + tallInfo.height.should.equal(400); + }); + }); +}); diff --git a/test/specs/rotate.spec.ts b/test/specs/rotate.spec.ts new file mode 100644 index 0000000..18a5c41 --- /dev/null +++ b/test/specs/rotate.spec.ts @@ -0,0 +1,51 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir} from "fs"; + +import {rotate} from "../../src/commands/rotate"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("rotate command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + it("should rotate an image", async () => { + const info = await rotate({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + degree: 90, + }); + + info.width.should.equal(200); + info.height.should.equal(400); + }); +}); diff --git a/test/specs/thumbail.spec.ts b/test/specs/thumbail.spec.ts new file mode 100644 index 0000000..3dd754e --- /dev/null +++ b/test/specs/thumbail.spec.ts @@ -0,0 +1,52 @@ +/* + EasyImage + + EasyImage is a promise-based image processing module + for Node.js, it is built on top of ImageMagick, so + make sure ImageMagick is installed on your system. + + Copyright (c) 2015 Hage Yaapa + Maintained by Kevin Gravier + + MIT License + */ + +import "mocha"; +import * as chai from "chai"; +import * as chaiAsPromised from "chai-as-promised"; +import * as rimraf from "rimraf"; +import {mkdir} from "fs"; + +import {thumbnail} from "../../src/commands/thumbnail"; + +chai.use(chaiAsPromised); +chai.should(); + +const files = `${__dirname}/../files`; +const output = `${__dirname}/../output`; + +describe("thumbnail command", () => { + beforeEach((done: () => void) => { + try { + mkdir(output, done); + } catch (e) { + done(); + } + }); + + afterEach((done: () => void) => { + rimraf(output, done); + }); + + it("should create a thumbnail", async () => { + const info = await thumbnail({ + src: `${files}/wide.png`, + dst: `${output}/wide.png`, + width: 100, + height: 100, + }); + + info.width.should.equal(100); + info.height.should.equal(100); + }); +}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 73b889b..0000000 --- a/test/test.js +++ /dev/null @@ -1,330 +0,0 @@ -var chai = require('chai'); -var chaiAsPromised = require('chai-as-promised'); -chai.use(chaiAsPromised); -chai.should(); -var assert = chai.assert; -var fs = require('fs'); -var rimraf = require('rimraf'); - -var outputDir = './output'; -if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir); -} - -var easyimg = require('../lib/EasyImage.js'); -var srcimg = 'kitten.jpg'; - -describe('.info - ', function () { - describe('valid file type', function () { - it('should show file info', function () { - return easyimg.info(srcimg).then(function (file) { - //console.log(file); - file.should.be.an('object'); - file.should.have.property('name'); - file.name.should.be.a('string'); - file.should.have.property('path'); - file.path.should.be.a('string'); - file.should.have.property('type'); - file.type.should.be.a('string'); - file.should.have.property('width'); - file.width.should.be.a('number'); - file.should.have.property('height'); - file.height.should.be.a('number'); - file.should.have.property('depth'); - file.depth.should.be.a('number'); - file.should.have.property('size'); - file.size.should.be.a('number'); - file.should.have.property('density'); - file.density.should.be.an('object'); - file.density.should.have.property('x'); - file.density.x.should.be.a('number'); - file.density.should.have.property('y'); - file.density.y.should.be.a('number'); - }) - }); - }); - - describe('invalid file type', function () { - it('should not be supported', function () { - return assert.isRejected(easyimg.info('./test.js'), "The issued command is unsupported"); - }); - }); - -}); - -describe('.convert -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/convert.png', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should convert an image format to another', function () { - - return easyimg.convert({ - src: srcimg, - dst: __dirname + '/output/convert.png', - quality: 10 - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('type'); - file.type.should.be.equal('png'); - file.name.should.be.equal('convert.png'); - }); - }); - - it("should convert a multi-page pdf to a single image", function () { - return easyimg.convert({ - src: "test.pdf", - dst: __dirname + "/output/convert.png" - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('type'); - file.type.should.be.equal('png'); - file.name.should.be.equal('convert.png'); - file.height.should.be.equal(1584); - }); - }); - -}); - -describe('.rotate -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/rotated.jpg', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should rotate the image by 90 degree', function () { - return easyimg.info(srcimg).then(function (info) { - info.should.have.property('width'); - info.should.have.property('height'); - - // Mainly check only if width and height are swapped - return easyimg.rotate({ - src: srcimg, - dst: __dirname + '/output/rotated.jpg', - degree: 90 - }).then(function (file) { - file.should.be.a('object'); - file.name.should.be.equal('rotated.jpg'); - file.should.have.property('width'); - file.width.should.be.equal(info.height); - file.height.should.be.equal(info.width); - }); - }) - }); - -}); - -describe('.resize -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/resize.jpg', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should resize an image with preserved aspect ratio', function () { - return easyimg.resize({ - src: srcimg, - dst: __dirname + '/output/resize.jpg', - width: 640, - height: 400 - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - /* - * The original aspect ratio is equal ~1.333. - * Imagemagick calculates it with the lowest common - * denominator in our case the height, thats why it is - * preserved and width will be adjusted as follow - * 400 * 1.33 = ~533 - */ - file.width.should.be.equal(533); - file.height.should.be.equal(400); - file.name.should.be.equal('resize.jpg'); - }); - - }); - - it("should resize an image with ignored aspect ratio", function () { - return easyimg.resize({ - src: srcimg, - dst: __dirname + '/output/resize.jpg', - width: 640, - height: 400, - ignoreAspectRatio: true - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - file.width.should.be.equal(640); - file.height.should.be.equal(400); - file.name.should.be.equal('resize.jpg'); - }); - }); - - it("should resize a tall image to a specified width while maintaining aspect ratio", function () { - return easyimg.resize({ - src: "./yolo-tall.png", - dst: __dirname + '/output/resize.jpg', - width: 10 - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - file.width.should.be.equal(10); - file.height.should.be.equal(25); - file.name.should.be.equal('resize.jpg'); - }); - }); - - it("should not upscale an image if downscaleOnly is true", function () { - return easyimg.resize({ - src: srcimg, - dst: __dirname + '/output/resize.jpg', - width: 1000, - onlyDownscale: true - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - file.width.should.be.equal(800); - file.name.should.be.equal('resize.jpg'); - }); - }); -}); - -describe('.crop -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/crop.jpg', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should crop an image', function () { - return easyimg.crop({ - src: srcimg, - dst: __dirname + '/output/crop.jpg', - cropwidth: 128, - cropheight: 128, - gravity: 'North', - x: 0, - y: 0 - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - file.width.should.be.equal(128); - file.name.should.be.equal('crop.jpg'); - }); - - }); - -}); - -describe('.rescrop -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/rescrop.jpg', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should resize and crop', function () { - return easyimg.rescrop({ - src: srcimg, - dst: __dirname + '/output/rescrop.jpg', - width: 400, - height: 5400, - cropwidth: 100, - cropheight: 100, - x: 0, - y: 0 - }).then(function (file) { - file.should.be.a('object'); - file.should.have.property('width'); - file.width.should.be.equal(100); - file.name.should.be.equal('rescrop.jpg'); - }); - - }); - -}); - -describe('.thumbnail -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/thumb nail.jpg', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - //this.timeout(5000); - it('should generate a thumbnail', function () { - return easyimg.thumbnail({ - src: srcimg, - dst: __dirname + '/output/thumb nail.jpg', - width: 128, - height: 128, - x: 0, - y: 0 - }).then(function (file) { - file.should.be.a("object"); - file.should.have.property('width'); - file.width.should.be.equal(128); - file.name.should.be.equal('thumb nail.jpg'); - }); - - }); - -}); - -describe('.execute -', function () { - - afterEach(function (done) { - fs.unlink(__dirname + '/output/hello kitty.gif', function () { - /* ignore any error unlinking */ - done(); - }); - }); - - it('should invoke `convert` command', function () { - return easyimg.execute('convert', [srcimg, './output/hello\\ kitty.gif']); - - }); - -}); - -describe('additionals', function () { - - afterEach(function (done) { - rimraf(__dirname + '/output/foo/', function () { - done(); - }); - }); - - //this.timeout(5000); - it('should create directories if they do not exist', function () { - - return easyimg.thumbnail({ - src: srcimg, - dst: __dirname + '/output/foo/bar/hey.jpg', - width: 128, - height: 128, - x: 0, - y: 0 - }).then(function (file) { - file.should.be.a('object'); - file.name.should.be.equal('hey.jpg'); - }); - - }); - -}); diff --git a/test/yolo-tall.png b/test/yolo-tall.png deleted file mode 100644 index 81270a448906316cddfa8932990b1844c856c02b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 762 zcmVAauQa}nwY+1!NsH$oWzydG;8UQt2IsiD)=gv8Iit5-o zC#nF}0FD5huxg4f7Fe84DZA1#d zQ-NAEo)E+rD+Jooz2XO#EX^F0VNZOa3~g9S#57BzDVEJtQmiS*i2_nU-uB4p<3_He zDDB7@IHFwj^&Q&W()jTGFGUmdlFHP0W&5fXBiho7iV=O+D@GFl(Tb6HJRyimG0Fup zsu(RS-JN2j1-Vmm1jKlw>a1=KlfJ(8WB6a7gR zV>Kf{`?*N^C=d=5=AvD!{p8xd-e&q>x!PxdOaZB6iBjk+RRA1w07zfSj{%$kY;plec8whYXp!(A0ZEk_>o0(B=iKF4 sLd^i+EBbFbImNu9#TSqQQb2^|4~b5okrShJi2wiq07*qoM6N<$g5?NGrvLx| diff --git a/test/yolo.png b/test/yolo.png deleted file mode 100644 index 4fd82d1e4a39866161d90828ac93ff9d5f12d70e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1555 zcmeAS@N?(olHy`uVBq!ia0vp^AwaCe!3HD`3jC7=Qj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS=07??FOLn2Bde0{8v^KVPg@)As;uP=V3xw&xF#U(+h2=`(&xHzP; zAXPsowK%`DC>a=WY04n03ap%qQWHz^i$e1Ab6}wukda@KU!0L&py2Eb4mAZ0-^Aq1 zJdmI!SeLJ_m1kaYNn&1ds;7&s63`sI%*+%k3uhB2b5nCmS4$^zLqk^+Cld=}XEPT! z6AMdIM`t%Pm|mCsATTydg8Hk9+#%&IGzI zx8#rFd}i!EAP@{gTSRkG9cNivt@}5p@CBR^>p!qm&EPW%2-LmnI4h*9>&3Fl zr1lMOPCk!b|2XRO{VD(doZbBA_x-bis$RmrC8wh9se2jq-~OU$_3fP*?>zo#Op(v8 zSbbyTTD(JPUUa3MN7IW3{Be`|lz%Op?=}0(HN6v3&#yb?`e)v%+NK)+IzY|Lddj@D zsV{e45ZvND!bZixeXXruF#ox; export declare function applyDefaultsToBaseOptions(options: IBaseOptions): void; export declare function applyBaseOptionsToArgs(options: IBaseOptions, args: string[]): void;