Skip to content

Commit

Permalink
Ready for signing
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Moreno committed Jul 15, 2019
1 parent f40d185 commit 60ed820
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 103 deletions.
50 changes: 4 additions & 46 deletions CSXS/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifest Version="9.0" ExtensionBundleId="com.santiagomoreno.quickfire" ExtensionBundleVersion="1.0.0"
ExtensionBundleName="Quick Fire" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
ExtensionBundleName="QuickFire" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ExtensionList>
<Extension Id="com.santiagomoreno.quickfire" Version="1.0.0" />
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<!-- Uncomment tags according to the apps you want your panel to support
Make sure to change these tags to use realistic version ranges before releasing your extensions, not 99.9!
You may also need to change the CEP version in order to support certain apps. -->

<!-- Photoshop -->
<Host Name="PHXS" Version="[16.0,99.9]" />
<Host Name="PHSP" Version="[16.0,99.9]" />

<!-- Illustrator -->
<!-- <Host Name="ILST" Version="[18.0,99.9]" /> -->

<!-- InDesign -->
<!-- <Host Name="IDSN" Version="[10.0,99.9]" /> -->

<!-- InCopy -->
<!-- <Host Name="AICY" Version="[10.0,99.9]" /> -->

<!-- Premiere -->
<!-- <Host Name="PPRO" Version="[8.0,99.9]" /> -->

<!-- AfterEffects -->
<!-- <Host Name="AEFT" Version="[13.0,99.9]" /> -->

<!-- PRELUDE -->
<!-- <Host Name="PRLD" Version="[3.0,99.9]" /> -->

<!-- Animate -->
<!-- <Host Name="FLPR" Version="[14.0,99.9]" /> -->

<!-- Audition -->
<!-- <Host Name="AUDT" Version="[8.0,99.9]" /> -->

<!-- Dreamweaver -->
<!-- <Host Name="DRWV" Version="[16.0,99.9]" /> -->

</HostList>
<LocaleList>
<Locale Code="All" />
Expand All @@ -55,30 +22,21 @@
<Resources>
<MainPath>./index.html</MainPath>
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
</CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
</CEFCommandLine>
<ScriptPath>./jsx/hostscript.jsx</ScriptPath>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>Quick Fire</Menu>
<Menu>QuickFire</Menu>
<Geometry>
<Size>
<Height>300</Height>
<Width>300</Width>
</Size>
<!--<MinSize>
<Height>550</Height>
<Width>400</Width>
</MinSize>
<MaxSize>
<Height>550</Height>
<Width>400</Width>
</MaxSize>-->

</Geometry>
<Icons>
<Icon Type="Normal">./icons/iconNormal.png</Icon>
Expand Down
4 changes: 2 additions & 2 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ h3 {
text-transform: uppercase;
font-size: 10px;
letter-spacing: 1px;
margin-bottom: 10px;
margin-bottom: 5px;
}

h4 {
Expand Down Expand Up @@ -100,7 +100,7 @@ select.is-pressed{
}

section {
margin-bottom: 10px;
margin-bottom: 15px;
}

.h-group {
Expand Down
Binary file modified icons/iconDarkNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/iconDarkRollover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/iconDisabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/iconNormal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/iconRollover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/styles.css" />
<title>QuickFire</title>
<title>🔥 QuickFire</title>
</head>

<body>
Expand Down
22 changes: 14 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@


var cs = new CSInterface();
var gExtensionId = "com.santiagomoreno.quickfire";

function Persistent(inOn) {

if (inOn) {
var event = new CSEvent("com.adobe.PhotoshopPersistent", "APPLICATION");
} else {
var event = new CSEvent("com.adobe.PhotoshopUnPersistent", "APPLICATION");
}
event.extensionId = gExtensionId;
cs.dispatchEvent(event);
}

function loadJSX(fileName) {
var extensionRoot = cs.getSystemPath(SystemPath.EXTENSION) + "/jsx/";
Expand All @@ -23,6 +35,8 @@
document.querySelector("#debug").addEventListener('click', function() { cs.openURLInDefaultBrowser("http://localhost:8088"); } );

function init() {

Persistent(false)

loadJSX('json.js')

Expand Down Expand Up @@ -50,10 +64,6 @@
layerDropdown.appendChild(el)
}
});

// document.getElementById("btn_test").addEventListener('click', function () {
// csInterface.evalScript('sayHello()');
// });

document.getElementById("input_file").addEventListener('click', function () {
evalScript(`selectFiles()`)
Expand Down Expand Up @@ -83,10 +93,6 @@
alert('No input or output specified')
} else {
evalScript(`run("${layerDropdown.options[layerDropdown.selectedIndex].value}","${inputFolder}","${outputFolder}","${formatDropdown.options[formatDropdown.selectedIndex].value}")`)
.then(function(res) {
// return evalScript(`selectFiles()`)
// console.log(res)
});
}
});

Expand Down
78 changes: 32 additions & 46 deletions jsx/hostscript.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ function getLayers() {
collectAllLayers(theLayer, allLayers);
}
}
// alert(allLayers);
res = allLayers;
}

return res
}

function filterFiles(file){
if (file.constructor.name == "Folder") { return true }
if(file.name.match(/\.(jpg|jpeg|png)$/)){return true}
return false
}

function selectFiles(){
var input = File.openDialog("Select Files", "*.*",true)
// files = input.getFiles(/\.(jpg|tif|psd|bmp|gif|png|psb|)$/i)
var input = File.openDialog("Select Files",filterFiles,true)

files = input

if (input != undefined) {
// for (var i = 0; i < input.length; i++) {
// alert(input[i])
// }
if (input.length > 1) {
return '[Multiple files selected]'
} else {
Expand All @@ -66,7 +66,7 @@ function selectFiles(){

function output(){
var input = Folder.selectDialog("Select Output Folder")
// var files = input.getFiles(/\.(jpg|tif|psd|bmp|gif|png|)$/i)

if (input != null) {
var inputData = {
name: input.name,
Expand All @@ -83,37 +83,23 @@ function output(){
function run(value, source, target, format){
var doc = activeDocument;

// alert(value)
if(value == "selected"){
returnLayer(activeDocument.activeLayer, files, target, format)
} else {
// alert('finding')
findLayer(doc, value, source, target, format)

findLayer(doc, value, files, target, format)
}
// for (var i = 0; i < files.length; i++) {
// var selected = files[i];
// parent = replaceContents(selected, parent)
// // Save JPG
// activeDocument.saveAs((new File(thePath + '/Edited/' + activeDocument.name + '_' +selected.name + ".jpg")), jpgSaveOptions, true,Extension.LOWERCASE);

// }
}

function findLayer(parent, value, source, target) {

function findLayer(parent, value, source, target, format) {
var layers = parent.layers;
var len = layers.length;
var match = false;

// iterate through layers to find a match
for (var i = 0; i < len; i++) {

// test for matching layer
var layer = layers[i];
if (layer.name.toLowerCase() == value.toLowerCase()) {
// select matching layer
// alert('finding layer')
activeDocument.activeLayer = layer;
match = true;
break;
Expand All @@ -126,46 +112,46 @@ function findLayer(parent, value, source, target) {
}
}
}
// alert(match)
if (match) {
returnLayer(activeDocument.activeLayer, source, target)
alert('matched')
returnLayer(activeDocument.activeLayer, source, target, format)
}
}


function returnLayer(parent, source, target, format) {
if(parent.kind == "LayerKind.SMARTOBJECT") {
// var input = new Folder(source)
// var files = input.getFiles(/\.(jpg|tif|psd|bmp|gif|png|)$/i)
// var subFolder = new Folder(activeDocument.path + '/Edited/')
// if (!subFolder.exists){subFolder.create()};
// alert(format)
alert(source.length)

if (source.length > 1) {
if (source.length > 1) {
for (var i = 0; i < source.length; i++) {
var selected = source[i];
parent = replaceContents(selected, parent)
if(format == "jpg") {
// Save JPG
activeDocument.saveAs((new File(target + '/' +selected.name + ".jpg")), jpgSaveOptions, true,Extension.LOWERCASE);
} else if (format == "png8") {
activeDocument.exportDocument((new File(target + '/' +selected.name + ".png")), ExportType.SAVEFORWEB, png8Options);
} else if (format == "png24") {
activeDocument.saveAs((new File(target + '/' +selected.name + ".png")), pngOptions, true,Extension.LOWERCASE);
}
saveImage(selected, format, target, parent)
}
openOutput(target)
} else {
alert(source.length)
var selected = source[0];
saveImage(selected, format, target, parent)
openOutput(target)
}
} else {
alert("Selected layer is not a Smart Object")
}
}

function saveImage(selected, format, target, parent) {
var filename = selected.name.split('.').slice(0, -1).join('.')

parent = replaceContents(selected, parent)
if(format == "jpg") {
activeDocument.saveAs((new File(target + '/' + filename + ".jpg")), jpgSaveOptions, true,Extension.LOWERCASE);
} else if (format == "png8") {
activeDocument.exportDocument((new File(target + '/' + filename + ".png")), ExportType.SAVEFORWEB, png8Options);
} else if (format == "png24") {
activeDocument.saveAs((new File(target + '/' + filename + ".png")), pngOptions, true,Extension.LOWERCASE);
}
}

function replaceContents(newFile, theSO) {
activeDocument.activeLayer = theSO;
// =======================================================
var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
Expand Down

0 comments on commit 60ed820

Please sign in to comment.