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

Script for export from eps to jpg done. Just need to know jpg pixel dimensions?

$
0
0

i have a script which export eps to jpg using below script (width is always 1276 px). Is there any way to know the dimension of the each jpg files as an alert?

 

#target illustrator
var i,  files, sourceDoc, targetFile;

files = File.openDialog ("Hi, Please select EPS file(s)", /.eps$/, true);

try
{
if (files.length > 0)
{
  for ( i = 0; i < files.length; i++ )
  {
        sourceDoc = app.open(files[i]);
        var myVisibleBounds = sourceDoc.visibleBounds;
        myVisibleBounds[0] = myVisibleBounds[0] - 1;  // left
        myVisibleBounds[1] = myVisibleBounds[1] + 0.5;   // top
        myVisibleBounds[2] = myVisibleBounds[2] + 1;   // right
        myVisibleBounds[3] = myVisibleBounds[3] - 1 ;    // bottom

        sourceDoc.artboards[0].artboardRect = myVisibleBounds;

//        var docLeft = sourceDoc.artboards[0].artboardRect[0] - 50;
//        var docTop = sourceDoc.artboards[0].artboardRect[1] + 50;
//        var docRight = sourceDoc.artboards[0].artboardRect[2] + 50 ;
//        var docBottom = sourceDoc.artboards[0].artboardRect[3] -50 ;

        var sourceDocWidth = Math.round(myVisibleBounds[2] - myVisibleBounds[0]);

//        var sourceDocHeight = docTop - docBottom;

        var myZoom = (1276/sourceDocWidth) * 100;
//        alert(sourceDocWidth + " Math round: " + Math.round(sourceDocWidth) + "   " + myZoom);

        targetFile = getNewName();
   // Call function getPDFOptions get the PDFSaveOptions for the files
        exportOptions = exportJPEG( );
   // Save as pdf
   sourceDoc.exportFile (targetFile, ExportType.JPEG, exportOptions);
   sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
     }
  alert( "Done" );
       
}
}
catch(e)
{
    alert(e +  "\r" + "No files selected");
};

 

function getNewName()
{
var ext, docName, newName, saveInFile, docName;
docName = sourceDoc.name;
//ext = '.pdf'; // new extension for pdf file
newName = "";
 
for ( var i = 0 ; docName[i] != "." ; i++ )
{
        newName = newName + docName[i];
}
newName = newName;
saveInFile = new File(sourceDoc.path + '/' + newName );

    return saveInFile;
}

 

function exportJPEG()
{
    var exportOptions = new ExportOptionsJPEG();
    exportOptions.artBoardClipping = true;
    exportOptions.antiAliasing = false;
    exportOptions.qualitySetting = 100;
    exportOptions.horizontalScale = myZoom;
    exportOptions.verticalScale   = myZoom;
//    exportOptions.transparency = false;
//exportOptions.saveAsHTML = true;
   
    return exportOptions;
       
}


Viewing all articles
Browse latest Browse all 12845

Trending Articles



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