/* ================================================================================================================ * * * * File Name : GarmentCreator for Photoshop.jsx * * Description: EPSON Garment Creator for Adobe Photoshop ExtendScript Toolkit * * * * ================================================================================================================ * * Copyright (C) SEIKO EPSON CORPORATION 2013, All rights reserved. * * ================================================================================================================ * * history : Rev Date Name Description * * 1.0.2 2013.09.25 akasaka initial * * ================================================================================================================ */ #target photoshop var appFolder = ""; var garmentCreatorFolder = "/GarmentCreator/Local Store/"; var macPreferences = "~/Library/Preferences"; if( Folder.fs == "Windows") { appFolder = Folder.userData + garmentCreatorFolder; } else { appFolder = macPreferences + garmentCreatorFolder; } if( openFile() ) { filePath = exportImage(); writeParam( filePath ); execApp(); } function openFile() { if ( app.documents.length < 1 ) { openfileName = File.openDialog("Select file",false); if (openfileName){ openfileObj = new File(openfileName); app.open(openfileObj); } else{ return false; } } return true; } function exportImage() { fileName = "/temporary"; folder = new Folder( appFolder + "Plugin" ); folder.create(); fileObj= new File( folder.fsName + fileName + ".tif" ); tiffOpt = new TiffSaveOptions(); tiffOpt.alphaChannels = true; tiffOpt.layerCompression = LayerCompression.ZIP; activeDocument.saveAs(fileObj, tiffOpt, true, Extension.LOWERCASE); return fileObj.fsName; } function writeParam( filePath ) { clavesPrm = new File( appFolder + "GarmentCreatorParameter" ); clavesPrm.encoding = "UTF-8"; encPath = File.encode( filePath ); decPath = File.decode( encPath ); clavesPrm.open("w"); clavesPrm.write( decPath ); clavesPrm.close(); } function execApp() { clavesIF = new File( appFolder + "GarmentCreatorInterface" ); clavesIF.open("r"); clavesPath = clavesIF.readln(); claves = new File( clavesPath ); claves.execute(); } function IsMacOSX() { var userDir = Folder.userData; return ( userDir .charAt(0) == '~' ); }