Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added flatten support #53

Merged
merged 1 commit into from

3 participants

@jwarchol

Includes a layered PSD, example and test. Should help issue #52

@jwarchol jwarchol Added flatten support
Includes a layered PSD, example and test.
16a1751
@aheckmann
Owner

LGTM. I'm traveling this week but I'll merge it in soon.

Thanks!

@jwarchol

I wasn't sure if you'd dig having the PSD in the repo or not. I'm not sure what else -flatten is good for. I imagine there are a few image formats that have layers it can smush.

Safe travels. Looks like you ran into my friend and former co-worker Steve Agalloco (@anno) down in Charlotte. Small world

@gerred

This is actually exactly what I'm looking for with my prior issue. Thanks so much.

@aheckmann aheckmann merged commit cab637b into aheckmann:master
@aheckmann
Owner

merged. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2012
  1. @jwarchol

    Added flatten support

    jwarchol authored
    Includes a layered PSD, example and test.
This page is out of date. Refresh to see the latest.
View
12 examples/flatten.js
@@ -0,0 +1,12 @@
+// gm - Copyright Aaron Heckmann <aaron.heckmann+github@gmail.com> (MIT Licensed)
+
+var gm = require('../')
+ , dir = __dirname + '/imgs'
+
+gm(dir + '/layers.psd')
+ .flatten()
+ .write(dir + "/unlayered.jpg", function(err){
+ if (err) return console.dir(arguments)
+ console.log(this.outname + " created :: " + arguments[3])
+ }
+)
View
BIN  examples/imgs/layers.psd
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
5 lib/args.js
@@ -386,6 +386,11 @@ module.exports = function (proto) {
, "South"
, "SouthEast"
];
+
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-flatten
+ proto.flatten = function flatten () {
+ return this.out("-flatten");
+ }
};
/**
View
12 test/flatten.js
@@ -0,0 +1,12 @@
+var assert = require('assert')
+
+module.exports = function (img, dir, finish, gm) {
+ var changed = gm('whatever.png').gravity("Souths")
+ assert.equal(changed._out[1], 'NorthWest');
+
+ gm(dir + '/layers.psd')
+ .flatten()
+ .write(dir + '/unlayered.jpg', function (err) {
+ finish(err);
+ });
+}
Something went wrong with that request. Please try again.