Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

mm -> px horizontalScale rounding

$
0
0

Hi all.

 

Quite new to Ai's scripting stuff.

 

I'm having a complicate time with Ai's save to jpg options vs artboard sizes and units conversions.

 

Say, i have a doc (from my client), which they inherited and enhanced for 10 years may be.

 

It's "supposed" to be in millimeters, but artboardRect gives me those values :

-0.27880000000005

436.191388980878

646.457

-0.20900000000074

 

which sound like weird points or pixels.

 

I need to export a jpg (or gif, or png), that will be X pixels wide. For the purpose of the test i set it at 1200.

 

var maxLargeurPx = 1200;

 

First thing, getting the artboard's width :

 

largeurArtboard = Math.abs(thisArtboardRect[2]-thisArtboardRect[0]);

// 646.7358

 

Then i try to have a multiply factor to use

 

coefExport = /*Math.round*/ (100 * maxLargeurPx / largeurArtboard);

// 185.54717397738

 

and then set my ExportFile jpg to this value (i can't give it a number)

 

     // exportOptions.horizontalScale = coefExport

 

That's when it's getting fun : my images are 1204 px wide with or without clipping.

 

Of course, i "can't" resize the doc for each export, especially expecting to have dozens of those, with different values, dimensions, etc.

 

Any idea is welcome


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>