Sort by aspect ratio


#1

So far as I can see, there’s no way to sort images by aspect ratio, eg to separate out landscape and portrait format images. This would be very useful for several workflows.


Document, jsnode, asset API?
#2

I’ve been working on adding plugin support to Retrobatch, and this is a pretty simple example to implement it in so that’s what I’ve done. Here’s how to do it:

Grab the latest build of Retrobatch: http://flyingmeat.com/download/latest/#retrobatch

Download this plugin: http://flyingmeat.com/stuff/rbplugin/SeparateLandscapeandPortrait.retrobatchplugin.zip

Launch Retrobatch at least once, and then open up your ~/Library/Application Support/Retrobatch/Plug-Ins/ folder. Then unzip the SeparateLandscapeandPortrait.retrobatchplugin.zip archive, and put it in the Plug-Ins folder. Relaunch Retrobatch.

A new node named “Separate Landscape and Portrait” will show up under the “Plug-In” category (though it may be spelled “Plugin” in your build). Drag and drop that into the canvas and see if that does the trick for you!

There’s a good chance this will break in a future release, but I’ll try and keep it updated. For the curious, here’s what the plugin looks like:

module.exports = {

    // Input Keys must always start with 'input'
    inputKeys: ["inputRemoveLandscape"],

    attributes: {
        "inputRemoveLandscape": {
            displayName: "Remove Landscape",
            default: 1,
            type: kCIAttributeTypeBoolean,
        }
    },

    checkImage(rbnode, asset) {
    
        var w = asset.imageWidth();
        var h = asset.imageHeight();
        var rejectLandscape = rbnode.nodeValues().inputRemoveLandscape;
    
        if (w == h) {
            return true; // Return true for all square images. It's both!
        }
    
        var isLandscape = w > h;
    
        if (rejectLandscape && isLandscape) {
            return false;
        }
    
        if (!rejectLandscape && !isLandscape) {
            return false;
        }
    
        return true;
    },

    preflightAsset: function(document, rbnode, asset) {
        return this.checkImage(rbnode, asset);
    },

    processAsset: function(document, rbnode, asset) {
        return this.checkImage(rbnode, asset);
    },

};

#3

Download this plugin: http://flyingmeat.com/stuff/rbplugin/SeparateLandscapeandPortrait.retrobatchplugin.zip

This is no longer available? I guess I can do this using Rules.


#4

It’s back up- sorry switched servers and a couple of things didn’t make it over.

I’ve been putting new plugins up here as well: https://github.com/ccgus/Retrobatch-Samples/tree/master/plugin