Jump to content

Recommended Posts

Posted

Good Morning All! 

I am currently attempting to find a replacement for Adobe Fireworks as the business I'm employed by would like to move away from the costs involved with Adobe. 

We have narrowed it down to Affinity Photo as a necessity to have for the batch function but also a luxury to have the Photoshop capabilities to use on the rare occasion. 

We had some custom scripts written which we imported into Fireworks. I cannot get the same end result with solely the batch process function within Affinity. 

Below is the script contents that were written for us for Fireworks. Is it possible to automate this inside Affinity? 

Essentially we want the option point the batch tool to the files to resize multiple photo file formats into 1000 x 1000 72dpi. For example, If the image is 1000 x 500 before batching, we want the batch program to fill out to 1000 x 1000 with the colour white. We no longer require "makeResize" and only "makeLarge" within the script. 

 

var theDoc = fw.getDocumentDOM().filePathForRevert;
var origFile = Files.getDirectory(theDoc) + '/' + Files.getFilename(theDoc)
var newFile = 'file:///C|/batched/'+Files.getFilename(theDoc, true)

makeLarge()
makeResize(227, 227, '_m')
makeResize(75, 75, '_s')
makeResize(40, 40, '_t')

Files.deleteFileIfExisting(origFile)

function makeLarge() {
    var oldHeight = fw.getDocumentDOM().height;
    var oldWidth = fw.getDocumentDOM().width;

    if (oldHeight > oldWidth) {
        newWidth = 1000
        var temp = oldHeight/newWidth
        newHeight = oldHeight/temp
        newWidth = oldWidth/temp
    } else  {
        newHeight = 1000
        var temp = oldWidth/newHeight
        newWidth = oldWidth/temp
        newHeight = oldHeight/temp
    }
    
    fw.getDocumentDOM().setDocumentImageSize({left:0, top:0, right:newWidth, bottom:newHeight}, {pixelsPerUnit:72, units:"inch"}, true);
    fw.getDocumentDOM().setDocumentCanvasSize({left:0, top:0, right:1000, bottom:1000}, true);
    fw.getDocumentDOM().setDocumentCanvasColor("#ffffff", true);
    fw.getDocumentDOM().selectAll();
    fw.getDocumentDOM().align('center vertical', 'true')
    fw.getDocumentDOM().align('center horizontal', 'true')
        
    var theDoc = fw.getDocumentDOM().filePathForRevert;
    var theFolder = Files.getDirectory(theDoc)
    var theFilename = Files.getFilename(theDoc, true)
    var fullPath = theFolder + '/' + theFilename
    var theExtension = Files.getExtension(theDoc)
    
    fw.exportDocumentAs(null, newFile+'_l', ({applyScale:false, colorMode:"24 bit",exportFormat:"JPEG",jpegQuality:80,jpegSmoothness:0,jpegSubsampling:0,name:"JPEG - Better Quality",numEntiresRequested:0,percentScale:"100",useScale:true,xSize:0,ySize:0}))
}

function makeResize(height, width, ext) {
    fw.getDocumentDOM().setDocumentImageSize({left:0, top:0, right:height, bottom:width}, {pixelsPerUnit:72, units:"inch"}, true);
    fw.getDocumentDOM().setDocumentCanvasSize({left:0, top:0, right:height, bottom:width}, true);
    fw.getDocumentDOM().setDocumentCanvasColor("#ffffff", true);
    fw.getDocumentDOM().selectAll();
    fw.getDocumentDOM().align('center vertical', 'true')
    fw.getDocumentDOM().align('center horizontal', 'true')
        
    var theDoc = fw.getDocumentDOM().filePathForRevert;
    var theFolder = Files.getDirectory(theDoc)
    var theFilename = Files.getFilename(theDoc, true)
    var fullPath = theFolder + '/' + theFilename
    var theExtension = Files.getExtension(theDoc)

    fw.exportDocumentAs(null, newFile+ext, ({applyScale:false, colorMode:"24 bit",exportFormat:"JPEG",jpegQuality:80,jpegSmoothness:0,jpegSubsampling:0,name:"JPEG - Better Quality",numEntiresRequested:0,percentScale:"100",useScale:true,xSize:0,ySize:0}))
}

Convert for Web.jsf

  • Staff
Posted

Hi @itsowenhowarth,

Welcome to the forums. 

I'm afraid we do not support scripting for Macros / Batch. However, have a look at this thread. You might be able to create something similar using Equations: 

Thanks,

Gabe. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.