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

Set DPI for JPEG

Guest
Apr 01, 2013 Apr 01, 2013

Hi,

I need to export an AI file to JPG.

For that I am using the File->Export option of Adobe Illustrator.

1.jpg

Now I want to do the same by using JSX Script.

I need Four JPG images of different sizes (70,150, 300,900) .

What Resolution (DPI) should I use to get images of above mentioned sizes.. or how can i dynamically set the DPI while exporting AI to JPEG image file

Thaknks

Harsh

TOPICS
Scripting
1.4K
Translate
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
Adobe
Mentor ,
Apr 02, 2013 Apr 02, 2013

You can't JPEG export is fixed to 72DPI output… What you need to do is export using the scale factors to get the required number of pixels…

Translate
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
Guest
Apr 02, 2013 Apr 02, 2013

Hi Mark,

Thanks for instant reply...

can you please share me the code block if you have it...

I am using the following code:

Code

function artboardToJPGs(size)

{

/*

       var    win = new Window ("window", "Save NGC", undefined, {borderless: true})

        win.pnl = win.add("panel", [10, 10, 170, 60], "Please Wait");

        win.pnl.progBarLabel = win.pnl.add("statictext", [6, 5, 150, 55], "Creating JPEG: "+size+'x'+size);

        win.show ();

        */

   

        var idx, j, sizes, jpegOpt, doc, docName, dF, artBds, abName, scale, jpgFile, destinationFolder, originalImage;

       

        jpegOpt = new ExportOptionsJPEG();

        jpegOpt.Optimization = true;

        jpegOpt.QualitySetting = 100;

        jpegOpt.blurAmount=0;

        jpegOpt.artBoardClipping=true;

       

       

        dF=new Folder(Folder.desktop+'/AI Artboard PNGs');

        if ( !dF.exists ) dF.create();

        doc = app.activeDocument;

        docName=doc.name;

      

        artBds = doc.artboards;

    

        idx = artBds.getActiveArtboardIndex();

        abName = artBds[ idx ].name;

    

           var w= artBds[ idx ].artboardRect[2] - artBds[ idx ].artboardRect[0] ;

           var h=artBds[ idx ].artboardRect[1] - artBds[ idx ].artboardRect[3];

            var width=  100+ ( (size - w)/w ) * 100;

     

            var height=  100+ ( ( size - h )/h ) * 100;

            jpgFile = File( dF.fsName + '/harsh_' + size + 'x' + size + '.jpg' );

    

    

            //jpegOpt.horizontalScale =width;

           // jpegOpt.verticalScale = height;

            doc.exportFile( jpgFile, ExportType.JPEG ,jpegOpt );

           

        //    win.close();

           var autoFile = File( jpgFile.fsName.replace( /\s/g,  '-' ) );

   

            if ( autoFile.exists ) {

           

        $.writeln( 'File Created ' );

   

        autoFile.rename(  jpgFile.name.replace( '-', ' ' ) );

 

       

        }

          alert('done');

}

Translate
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
Mentor ,
Apr 02, 2013 Apr 02, 2013
LATEST

Add the lines… Where 300 is your required DPI

jpegOpt.horizontalScale = ( 300 / 72 ) * 100;

jpegOpt.verticalScale = ( 300 / 72 ) * 100;

Translate
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