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
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
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);
}
}
Copy link to clipboard
Copied
Thank you so much!
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
Copy link to clipboard
Copied
Thank you Laubender,
Yes, you are right.
Can you do that?
Kind Regards,
Sumit
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
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);
}
}
Copy link to clipboard
Copied
For script format.. use like below
Copy link to clipboard
Copied
Thank you so much!
Copy link to clipboard
Copied
Dear TPK,
Can I open, save report automatically?
Sumit
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);
}
}
Copy link to clipboard
Copied
Dear TPK,
Works fine but need to save report at Desktop also.
Regards,
Sumit
Copy link to clipboard
Copied
Change line 15 to..
var defaultFile = new File("~/Desktop/Report.xls");
Copy link to clipboard
Copied
or..
var defaultFile = new File("~/Desktop/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls");
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
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
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
Copy link to clipboard
Copied
Hi,
Can I get height and width of graphic text frames which is not scaling 100% in our report?
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
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)){
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
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")){
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
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)){
Copy link to clipboard
Copied
Dear Karthi,
Yes, your code is working nicely.
You are great.
Thank you so much.
Sumit