/* ================================================================================================================ * * * * File Name : GarmentCreator for Illustrator.jsx * * Description: EPSON Garment Creator for Adobe Illustrator ExtendScript Toolkit * * * * ================================================================================================================ * * Copyright (C) SEIKO EPSON CORPORATION 2013, All rights reserved. * * ================================================================================================================ * * history : Rev Date Name Description * * 1.0.2 2013.09.25 akasaka initial * * 1.0.5 2013.11.01 akasaka Fixed error of CS5 * * ================================================================================================================ */ #target illustrator 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() ) { var version = parseInt(app.version); // var aiWrite = ( version < 16 )? new aiWritePng() : new aiWriteTiff(); var aiWrite = new aiWritePng(); filePath = aiWrite.exportImage(); writeParam( filePath ); execApp(); } function aiWriteTiff() { this.exportImage = exportTiffImage; this.getOptions = getTIFFOptions; } function aiWritePng() { this.exportImage = exportPng24Image; this.getOptions = getPNG24Options; } 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 exportPng24Image() { fileName = "/temporary"; folder = new Folder( appFolder + "Plugin" ); folder.create(); fileObj= new File( folder.fsName + fileName + ".png" ); activeDocument.exportFile( fileObj, ExportType.PNG24, this.getOptions() ); retFile = new File( folder.fsName + fileName + ".png" ); return retFile.fsName; } function exportTiffImage() { fileName = "/temporary"; folder = new Folder( appFolder + "Plugin" ); folder.create(); fileObj= new File( folder.fsName + fileName + ".tif" ); activeDocument.exportFile( fileObj, ExportType.TIFF, this.getOptions() ); retFile = new File( folder.fsName + fileName + "-01.tif" ); return retFile.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 getTIFFOptions() { var exportOptions = new ExportOptionsTIFF(); exportOptions.resolution = 360; exportOptions.byteOrder = TIFFByteOrder.IBMPC; exportOptions.IZWCompression = true; exportOptions.saveMultipleArtboards = true; exportOptions.embedICCProfile = true; exportOptions.artBoardClipping = true; return exportOptions; } function getPNG24Options() { var exportOptions = new ExportOptionsPNG24(); exportOptions.verticalScale = 500; exportOptions.horizontalScale = 500; exportOptions.colorReduction = ColorReductionMethod.SELECTIVE; exportOptions.interlaced = false; exportOptions.transparency = true; exportOptions.artBoardClipping = true; return exportOptions; } function execApp() { clavesIF = new File( appFolder + "GarmentCreatorInterface" ); clavesIF.open("r"); clavesPath = clavesIF.readln(); claves = new File( clavesPath ); if( claves.exists ){ claves.execute(); } }