How to directly open images from Firefox?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

pecoes

How to directly open images from Firefox?

Post by pecoes »

Hi there

I frequently search the net for album art and more often than not the stuff I find needs a little editing. My current procedure is to copy the image to the clipboard, launch PS, create a new image and paste. A bit of a hassle. It would be great, if there were a way to automate that. The first half of the puzzle I did find already. There's an add-on called External Application Buttons mod that will allow me to launch PS from FF and switch to it. But not much else. It would work fine, if PS would accept command line parameters, but that doesn't seem to work... I also tried to create a droplet, that creates a new file from the clipboard and launch that from FF instead of PS. But that didn't work either...

Any idea how I should continue?

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

How to directly open images from Firefox?

Post by Paul MR »

On windows you can use VBS, just copy picture to the clipboard and run the script...
Code: Select allDIM objApp
SET objApp = CreateObject("Photoshop.Application")
REM Use dialog mode 3 for show no dialogs
DIM dialogMode
dialogMode = 3
DIM idMk
idMk = objApp.CharIDToTypeID( "Mk  " )
    DIM desc5
    SET desc5 = CreateObject( "Photoshop.ActionDescriptor" )
    DIM idNw
    idNw = objApp.CharIDToTypeID( "Nw  " )
        DIM desc6
        SET desc6 = CreateObject( "Photoshop.ActionDescriptor" )
        DIM idpreset
        idpreset = objApp.StringIDToTypeID( "preset" )
        Call desc6.PutString( idpreset, "Clipboard" )
    DIM idDcmn
    idDcmn = objApp.CharIDToTypeID( "Dcmn" )
    Call desc5.PutObject( idNw, idDcmn, desc6 )
Call objApp.ExecuteAction( idMk, desc5, dialogMode )
DIM idpast
idpast = objApp.CharIDToTypeID( "past" )
    DIM desc3
    SET desc3 = CreateObject( "Photoshop.ActionDescriptor" )
    DIM idAntA
    idAntA = objApp.CharIDToTypeID( "AntA" )
    DIM idAnnt
    idAnnt = objApp.CharIDToTypeID( "Annt" )
    DIM idAnno
    idAnno = objApp.CharIDToTypeID( "Anno" )
    Call desc3.PutEnumerated( idAntA, idAnnt, idAnno )
Call objApp.ExecuteAction( idpast, desc3, dialogMode )
pecoes

How to directly open images from Firefox?

Post by pecoes »

Wow! Thanks a lot! I didn't expect to get a complete script.

That puts me in an awkward positions, though. I can do CLI scripting just fine, but I'm useless when it comes to VB, I'm afraid.

So please forgive me, if I have to do a little bitching!

There are two issues with that script:
1.) PS isn't brought to the foreground and
2.) when I ran the script for the first time, I got an error message:



When I ran it for the second time, there was no error, but the image was sized incorrectly. It took on the size of the image that previously was in the clipboard - not the one that was currently in it. Same problem the next time around. And the next time.

Or to put it differently: If I click the "Open in PS" button twice, I get a wrongly sized image and a correct one. (Hope that was clear.)
Paul MR

How to directly open images from Firefox?

Post by Paul MR »

I know zero about VB this was some code that I found a while ago.
Another alternative is to have photoshop open, copy picture to clipboard and run the following javaScript.
You could create a shortcut or an action to call the script.
It does the same as the VB script except opening Photoshop.
Code: Select allnewDocFromClipboard();
try{
activeDocument.paste();
activeDocument.flatten();
}catch(e){}

function newDocFromClipboard(){
var idMk = charIDToTypeID( "Mk  " );
var desc1 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw  " );
var desc2 = new ActionDescriptor();
var idpreset = stringIDToTypeID( "preset" );
desc2.putString( idpreset, "Clipboard" );
var idDcmn = charIDToTypeID( "Dcmn" );
desc1.putObject( idNw, idDcmn, desc2 );
try{
executeAction( idMk, desc1, DialogModes.NO );
}catch(e){}
}
pecoes

How to directly open images from Firefox?

Post by pecoes »

Paul MR wrote:You could create a shortcut or an action to call the script

Sorry, I can't figure out how to do that.

But I've already created a new action by recording File->New and Edit->Paste. If I read this JS correctly, it does just that, right?