forked from ff6347/mpo-id-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpotential72dpi-detector.jsx
170 lines (153 loc) · 7.08 KB
/
potential72dpi-detector.jsx
1
// Copyright (c) 2013// Fabian "fabiantheblind" Morón Zirfas// Permission is hereby granted, free of charge, to any// person obtaining a copy of this software and associated// documentation files (the "Software"), to deal in the Software// without restriction, including without limitation the rights// to use, copy, modify, merge, publish, distribute, sublicense,// and/or sell copies of the Software, and to permit persons to// whom the Software is furnished to do so, subject to// the following conditions:// The above copyright notice and this permission notice// shall be included in all copies or substantial portions of the Software.// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIO// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.// see also http://www.opensource.org/licenses/mit-license.php(function (thisObj) { var potential72dpi = ["210131_00_n_d1b0c209.jpg", "212194_00_n_5637dceb.jpg", "212196_00_n_73b913b7.jpg", "246985_01_n_98fb372a.jpg", "288302_00_n_84a9552d.jpg", "300500_00_n_21f52dd5.jpg", "305374_00_n_2497fab7.jpg", "305377_00_n_8686aec8.jpg", "305378_00_n_e08a9ff8.jpg", "305379_00_n_e9d5eb43.jpg", "305381_00_n_814ad1b.jpg", "305383_00_n_14aa4fd5.jpg", "305384_00_n_f76515bc.jpg", "305387_00_n_a0e9526c.jpg", "309293_00_n_75c97331.jpg", "308974_00_n_d336a1c6.jpg", "309010_00_n_9a4c7669.jpg", "309294_00_n_504ecad3.jpg", "9109568_00_n_f5bb856b.jpg", "9109882_00_n_6025da47.jpg", "9111091_01_n_b2511047.jpg", "9111252_00_n_e43ac347.jpg", "9111677_02_n_76502930.jpg", "9111677_03_n_184f8826.jpg", "9112019_00_n_dcb4b69d.jpg", "9112188_01_n_3861aaa1.jpg", "9114937_00_n_482a9bcf.jpg", "9115028_04_n_6a52395d.jpg", "9115029_09_n_8c765635.jpg", "9115030_08_n_382029be.jpg", "9115225_00_n_744222b7.jpg", "9115226_00_n_382b76c9.jpg", "9116095_00_n_2182cf14.jpg", "9118765_00_n_5e8225d1.jpg", "9119014_00_n_38878b33.jpg", "9119407_00_n_c9f41908.jpg", "9119866_00_n_52715fa0.jpg", "9120537_01_n_e425b076.jpg", "9121640_00_n_8600963.jpg", "9121722_00_n_be32da8e.jpg", "9121910_00_n_23baade9.jpg", "9122717_00_n_4a6893.jpg", "9122826_00_n_d8619f08.jpg", "9123099_00_n_7def4cd.jpg", "9123101_00_n_4a4ff132.jpg", "9126900_00_n_3ff250c.jpg", "9127117_00_n_f74b2a03.jpg", "9127118_00_n_dea22c31.jpg", "9127186_00_n_58909fae.jpg", "9127187_00_n_dbdce96e.jpg", "9127347_00_n_bee179e1.jpg", "9127352_00_n_e961cfab.jpg", "9127736_00_n_212722b5.jpg", "9127853_00_n_27841c53.jpg", "9127853_01_n_79d1f117.jpg", "9127855_01_n_9b7d4cd9.jpg", "9127856_01_n_3ab137c7.jpg", "9127857_01_n_be4c42fa.jpg", "9128097_00_n_c135e561.jpg", "j0100389_00_n_7b6fedee.jpg", "j0103646_00_n_d20a1619.jpg", "131121_00_n_5e806461.jpg", "132791_00_n_d2b0f5a8.jpg", "154355_00_n_219d8f96.jpg", "200189_00_n_4f8feb04.jpg", "220700_00_n_6ab60842.jpg", "247702_00_n_ba9bdc5d.jpg", "249309_00_n_858665d1.jpg", "288414_05_n_6c3f0200.jpg", "289138_00_n_f564a977.jpg", "290091_00_n_db273a13.jpg", "298425_00_n_e60a10b6.jpg", "300017_00_n_668f564e.jpg", "9109995_00_n_20597064.jpg", "9109994_00_n_26574356.jpg", "9110040_00_n_9946c1c9.jpg", "9110367_00_n_1dd4a7a8.jpg", "9118812_00_n_2c778e3b.jpg", "9114718_00_n_75010a9f.jpg", "9119073_00_n_6a24b676.jpg", "9119346_00_n_7baf2f1f.jpg", "9119349_00_n_65066dd.jpg", "9122003_00_n_8ad0f05a.jpg", "9122550_00_n_f8212ddb.jpg", "9122564_00_n_9df9b211.jpg", "9122871_00_n_42e0a67e.jpg", "9125250_00_n_924fb151.jpg", "9125280_00_n_61df45ad.jpg", "9125297_00_n_ca1357ae.jpg", "9128398_00_n_a952b1df.jpg", "9128192_00_n_93724192.jpg", "9128476_00_n_54ebe095.jpg", "9128506_00_n_5160daf4.jpg", "9129160_00_n_618f66f4.jpg", "9128776_00_n_1b85bef9.jpg", "9128908_00_n_4ab323c0.jpg", "j0101287_00_n_bbd4d8f6.jpg", "120234_00_n_ba3116d3.jpg", "130014_00_n_e9cec62.jpg", "141653_00_n_cdb98a29.jpg", "147157_00_n_ac636155.jpg", "147167_00_n_70d3bea4.jpg", "153262_00_n_10cac426.jpg", "203357_00_n_5967d162.jpg" ]; alert("There are " + potential72dpi.length + " potentially wrong images from MrClipping"); // öffne Dokument "oneBook" des Buchesmain();function main(){ myDoc = app.activeDocument; var matches = "found these images:\n"; if (!myDoc) { alert("please open a document"); return; } var errorswatch = color_add(myDoc, "DETECTOR RED", ColorModel.PROCESS, [255,0,0]); myLinks = myDoc.links; for (var i = myLinks.length - 1; i > -1; i--) { link = myLinks[i]; for (var j = 0; j < potential72dpi.length; j++) { if (link.name == potential72dpi[j]) { link.parent.parent.fillColor = errorswatch; matches += link.name + "\n"; } } // if(myLink.status == LinkStatus.LINK_MISSING){ // } } var docpath = myDoc.filePath; var path = docpath + "/"+ myDoc.name+ "-potential72dpi-Detection-log.txt"; var write_file = File(path); if(!write_file.exists){ // if the file does not exist create one write_file = new File(path); }else{ // if it exsists ask the user if it should be overwritten var res = confirm ("The file already exists. Should I overwrite it", true, "titleWINonly"); // if the user hits no stop the script if(res !== true){ return; } } var out;// our output // we know already that the file exist // but to be shure if( write_file!=='' ){ //Open the file for writing. out = write_file.open( 'w', undefined, undefined ); write_file.encoding = "UTF-8"; write_file.lineFeed = "Unix"; //convert to UNIX lineFeed // txtFile.lineFeed = "Windows"; // txtFile.lineFeed = "Macintosh"; } // got an output? if( out !== false ){ // loop the list and write each item to the file write_file.write(matches); // allways close files! write_file.close(); }write_file.execute();} function color_add(myDocument, myColorName, myColorModel, myColorValue){ if(myColorValue instanceof Array === false){ myColorValue = [(parseInt(myColorValue, 16) >> 16 ) & 0xff, (parseInt(myColorValue, 16) >> 8 ) & 0xff, parseInt(myColorValue, 16 ) & 0xff ]; myColorSpace = ColorSpace.RGB; }else{ if(myColorValue.length == 3) myColorSpace = ColorSpace.RGB; else myColorSpace = ColorSpace.CMYK; } try{ myColor = myDocument.colors.item(myColorName); myName = myColor.name; } catch (myError){ myColor = myDocument.colors.add(); myColor.properties = {name:myColorName, model:myColorModel, space:myColorSpace ,colorValue:myColorValue}; } return myColor; }})(this);