• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

List of reduced or increased images with value

Engaged ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

Hi,

Can anyone modify jongware script below:

I need only those image list which is reduced or increase image size with percentage value but this script get all the image with percentage value. I do not need which image is 100%.

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 

list = []; 

imgs = app.activeDocument.allGraphics; 

unitname = getCurrentUnit(); 

for (i=0; i<imgs.length; i++) 

scale = roundMe(imgs.horizontalScale,1); 

// some fair rounding 

list.push (imgs.itemLink.name+'\t'+scale+'%'); 

// alert (list.join('\r')); exit(); 

defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls"); 

if (File.fs == "Windows") 

writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" ); 

else 

writeFile = defaultFile.saveDlg('Save report'); 

if (writeFile != null) 

if (writeFile.open("w")) 

  writeFile.encoding = "utf8"; 

  writeFile.write (list.join("\r")+"\r"); 

  writeFile.close(); 

function roundMe(val,to) 

var t = 1; 

while (to-- > 0) t *= 10; 

return Math.round(val*t)/t; 

function getCurrentUnit () 

switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits) 

  case MeasurementUnits.POINTS: return "pt"; 

  case MeasurementUnits.PICAS: return "pt"; 

  case MeasurementUnits.INCHES: return "in"; 

  case MeasurementUnits.INCHES_DECIMAL: return "in"; 

  case MeasurementUnits.MILLIMETERS: return "mm"; 

  case MeasurementUnits.CENTIMETERS: return "cm"; 

  case MeasurementUnits.CICEROS: return "c"; 

  case MeasurementUnits.AGATES: return "ag"; 

  default: alert ("Oh, come on!"); exit(0); 

Regards,

Sumit

-Sumit
TOPICS
Scripting

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Nov 17, 2016 Nov 17, 2016

Hi Sumit,

Here is the version with vertical scale value..

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;  

list = [];  

imgs = app.activeDocument.allGraphics;  

unitname = getCurrentUnit();  

for (i=0; i<imgs.length; i++)  

{  

scale = roundMe(imgs.horizontalScale,1);  

vscale = roundMe(imgs.verticalScale,1);  

// some fair rounding  

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){ 

list.push (imgs.itemLink.name+'\t'+scale+'%'+'\t'+vscale+'%'); } 

}  

// ale

...

Votes

Translate

Translate
Guide ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

Simply add a if condition in line 9.. it will work now

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

list = [];

imgs = app.activeDocument.allGraphics;

unitname = getCurrentUnit();

for (i=0; i<imgs.length; i++)

{

scale = roundMe(imgs.horizontalScale,1);

// some fair rounding

if(imgs.horizontalScale!=100){

list.push (imgs.itemLink.name+'\t'+scale+'%'); }

}

// alert (list.join('\r')); exit();

defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls");

if (File.fs == "Windows")

writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" );

else

writeFile = defaultFile.saveDlg('Save report');

if (writeFile != null)

{

if (writeFile.open("w"))

{

  writeFile.encoding = "utf8";

  writeFile.write (list.join("\r")+"\r");

  writeFile.close();

}

}

function roundMe(val,to)

{

var t = 1;

while (to-- > 0) t *= 10;

return Math.round(val*t)/t;

}

function getCurrentUnit ()

{

switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)

{

  case MeasurementUnits.POINTS: return "pt";

  case MeasurementUnits.PICAS: return "pt";

  case MeasurementUnits.INCHES: return "in";

  case MeasurementUnits.INCHES_DECIMAL: return "in";

  case MeasurementUnits.MILLIMETERS: return "mm";

  case MeasurementUnits.CENTIMETERS: return "cm";

  case MeasurementUnits.CICEROS: return "c";

  case MeasurementUnits.AGATES: return "ag";

  default: alert ("Oh, come on!"); exit(0);

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 16, 2016 Nov 16, 2016

Copy link to clipboard

Copied

Thank you so much!

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

Don't forget that there is also a vertical scale value.

And that could be a different to the horizontal one.


And how about skewd images?

( shearAngle )

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

Thank you Laubender,

Yes, you are right.

Can you do that?

Kind Regards,

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

Dear TPK,

Can you help me?

How to right in this forum as a script format as you write?

Kind Regards,

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

Hi Sumit,

Here is the version with vertical scale value..

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;  

list = [];  

imgs = app.activeDocument.allGraphics;  

unitname = getCurrentUnit();  

for (i=0; i<imgs.length; i++)  

{  

scale = roundMe(imgs.horizontalScale,1);  

vscale = roundMe(imgs.verticalScale,1);  

// some fair rounding  

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){ 

list.push (imgs.itemLink.name+'\t'+scale+'%'+'\t'+vscale+'%'); } 

}  

// alert (list.join('\r')); exit();  

defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls");  

if (File.fs == "Windows")  

writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" );  

else  

writeFile = defaultFile.saveDlg('Save report');  

if (writeFile != null)  

{  

if (writeFile.open("w"))  

{  

  writeFile.encoding = "utf8";  

  writeFile.write (list.join("\r")+"\r");  

  writeFile.close();  

}  

}  

function roundMe(val,to)  

{  

var t = 1;  

while (to-- > 0) t *= 10;  

return Math.round(val*t)/t;  

}  

function getCurrentUnit ()  

{  

switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)  

{  

  case MeasurementUnits.POINTS: return "pt";  

  case MeasurementUnits.PICAS: return "pt";  

  case MeasurementUnits.INCHES: return "in";  

  case MeasurementUnits.INCHES_DECIMAL: return "in";  

  case MeasurementUnits.MILLIMETERS: return "mm";  

  case MeasurementUnits.CENTIMETERS: return "cm";  

  case MeasurementUnits.CICEROS: return "c";  

  case MeasurementUnits.AGATES: return "ag";  

  default: alert ("Oh, come on!"); exit(0);  

}  

}  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

For script format.. use like below

Untitled.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 17, 2016 Nov 17, 2016

Copy link to clipboard

Copied

Thank you so much!

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Dear TPK,

Can I open, save report automatically?

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

like below?

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;    

list = [];    

imgs = app.activeDocument.allGraphics;    

unitname = getCurrentUnit();    

for (i=0; i<imgs.length; i++)    

{    

scale = roundMe(imgs.horizontalScale,1);    

vscale = roundMe(imgs.verticalScale,1);    

 

 

// some fair rounding    

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){   

list.push (imgs.itemLink.name+'\t'+scale+'%'+'\t'+vscale+'%'); }   

}    

defaultFile = new File (app.activeDocument.name.replace(/\.indd$/i, '')+".xls");    

if (defaultFile.open("w"))    

{    

  defaultFile.encoding = "utf8";    

  defaultFile.write (list.join("\r")+"\r");    

  defaultFile.close();    

  defaultFile.execute();

}    

function roundMe(val,to)    

{    

var t = 1;    

while (to-- > 0) t *= 10;    

return Math.round(val*t)/t;    

}    

function getCurrentUnit ()    

{    

switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)    

{    

  case MeasurementUnits.POINTS: return "pt";    

  case MeasurementUnits.PICAS: return "pt";    

  case MeasurementUnits.INCHES: return "in";    

  case MeasurementUnits.INCHES_DECIMAL: return "in";    

  case MeasurementUnits.MILLIMETERS: return "mm";    

  case MeasurementUnits.CENTIMETERS: return "cm";    

  case MeasurementUnits.CICEROS: return "c";    

  case MeasurementUnits.AGATES: return "ag";    

  default: alert ("Oh, come on!"); exit(0);    

}    

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Dear TPK,

Works fine but need to save report at Desktop also.

Regards,

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Change line 15 to..

var defaultFile = new File("~/Desktop/Report.xls"); 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

or..

var defaultFile = new File("~/Desktop/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls"); 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Dear TPK,

If you do not mind, can I ask your name please?

Both of your comment is file save only, not opening automatically.

Regards,

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

HI Sumit,

My name is Karthi.

Using    defaultFile.execute();  is to open the xls file automatically after you ran the script...

Just close the excel and try again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Dear Karthi,

Thank you so much!

I appreciated your reply.

I have used below script:

app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;      

list = [];      

imgs = app.activeDocument.allGraphics;      

for (i=0; i<imgs.length; i++)      

{      

scale = roundMe(imgs.horizontalScale,1);      

vscale = roundMe(imgs.verticalScale,1);      

   

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){     

list.push (imgs.itemLink.name+'\t'+scale+'%'); }     

}

var fName = app.activeDocument.name.replace(/\.indd$/i, '')+".txt";

defaultFile = new File ("~/Desktop/"+fName);

if (defaultFile.open("w"))      

{      

  defaultFile.encoding = "utf8";      

  defaultFile.write (list.join("\r")+"\r");      

  defaultFile.close();      

  defaultFile.execute(); 

}      

function roundMe(val,to)      

{      

var t = 1;      

while (to-- > 0) t *= 10;      

return Math.round(val*t)/t;      

}

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

LATEST

Hi,

Can I get height and width of graphic text frames which is not scaling 100% in our report?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 26, 2016 Nov 26, 2016

Copy link to clipboard

Copied

Dear Karthi,

When I use below line, that is not working.

Can you tell me what I am doing wrong?

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100) || (imgs.imageTypeName != "PDF")){

If I use EPS or JPEG then working but When I use PDF then not working.

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 26, 2016 Nov 26, 2016

Copy link to clipboard

Copied

Hi..

In your if condition you ignored the image type of PDF if comes.. So only you not get any results..try like below

if((imgs.imageTypeName == "PDF")){   \\ hope you know the difference of this != "PDF".. not sure why you check this

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 26, 2016 Nov 26, 2016

Copy link to clipboard

Copied

Dear Karthi,

I do not want to reduced pdf list because, In my document I have used pdf as a mini in teacher edition.

Same condition working with eps, ai and jpeg but not working with pdf only.

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 27, 2016 Nov 27, 2016

Copy link to clipboard

Copied

better try like

if(imgs.imageTypeName == "PDF"){continue;}

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100){

also like below

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100) || (imgs.imageTypeName != "Adobe PDF")){  

or

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100) || (imgs.imageTypeName !== "PDF")){  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 27, 2016 Nov 27, 2016

Copy link to clipboard

Copied

Dear Karthi,

Thank you so much!

Today, I learned from you "PDF" is not working but "Adobe PDF" is working.

Below code working nicely.

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100) || (imgs.imageTypeName != "Adobe PDF")){

But, Now problem is: Adobe PDF also escape .ai file. I need escape only .pdf file.

Regards

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 27, 2016 Nov 27, 2016

Copy link to clipboard

Copied

HI..

this maybe a solution.. try and let me know

if(app.activeDocument.allGraphics.itemLink.name.match(/\.pdf$/i) != null) {continue;}

if((imgs.horizontalScale!=100) ||(imgs.verticalScale!=100)){

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 28, 2016 Nov 28, 2016

Copy link to clipboard

Copied

Dear Karthi,

Yes, your code is working nicely.

You are great.

Thank you so much.

Sumit

-Sumit

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines