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

Change Export Raster Resolution?

Guest
Apr 18, 2011 Apr 18, 2011

Hello,

I am trying to use JavaScript to export layers to PNG... I have a working script, that is basically the same as the example in the Adobe Illustrator CS5 JavaScript Reference:

function exportFileToPNG24 (dest) {
     if ( app.documents.length > 0 ) {
          var exportOptions = new ExportOptionsPNG24();
          var type = ExportType.PNG24;
          var fileSpec = new File(dest);
          exportOptions.antiAliasing = false;
          exportOptions.transparency = false;
          exportOptions.saveAsHTML = true;
          app.activeDocument.exportFile( fileSpec, type, exportOptions );
     }
}

However, this will only export the document to 72ppi, and I don't see anywhere in ExportOptionsPNG24 to change this.

If you use Illustrator's UI, instead of scripting, and select File > Export... You get the option to select Screen (72ppi), Medium (150ppi), High (300ppi) or Other.

I found the DocumentRasterResolution constant in the reference, but I can't figure out how to change, or even access the constant?

I assume if I could reset the constant like:

DocumentRasterResolution = 3;

then the above script would export the file to a PNG @ 300 ppi?

TOPICS
Scripting
3.5K
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

correct answers 1 Correct answer

Community Expert , Apr 18, 2011 Apr 18, 2011

No it won't export at the higher resolution. The export of raster images is hardwired to 72 ppi for scripting. Why you can't use the same options available in the Export API is not known but that's the way it is.

edit:

I just made a new New Document Profile called test with a single artboard and a Raster Resolution setting of 72ppi. I then ran this script and it gave me a new document with 2 artboards and a Raster Resolution of 300 ppi.

#target Illustrator

var testPS = new DocumentPreset;
    testPS.

...
Translate
Adobe
Community Expert ,
Apr 18, 2011 Apr 18, 2011

Unfrotunately it's one of the many things in AI that are doable in the GUI and not from scripting. The best you can do is use the horizontal and vertical scale to make the image larger and then batch resize in Photoshop to get the resolution you want.

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 18, 2011 Apr 18, 2011

So, how does the DocumentRasterResolution constant get set in the first place?

Is there an option in the UI, like under File > Document Setup... ?

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
Guide ,
Apr 18, 2011 Apr 18, 2011

It is a menu item of Effect and refers to the resolution for rasterizing things such as drop shadow effects…

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 18, 2011 Apr 18, 2011

I don't think that is correct... otherwise, I should be able to change and save that setting in Effect > Document Raster Effects Settings ..., then my script would export at the higher resolution.

THAT particular raster setting has to do with the Document.rasterEffectSettings property... which is a RasterEffectsOptions object, and like the name implies deals with rasterization of effects... not the doc as a whole.

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
Community Expert ,
Apr 18, 2011 Apr 18, 2011

No it won't export at the higher resolution. The export of raster images is hardwired to 72 ppi for scripting. Why you can't use the same options available in the Export API is not known but that's the way it is.

edit:

I just made a new New Document Profile called test with a single artboard and a Raster Resolution setting of 72ppi. I then ran this script and it gave me a new document with 2 artboards and a Raster Resolution of 300 ppi.

#target Illustrator

var testPS = new DocumentPreset;
    testPS.numArtboards = 2;
    testPS.rasterResolution =  DocumentRasterResolution.HighResolution


app.documents.addDocument( "test", testPS);

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 18, 2011 Apr 18, 2011
LATEST

Yeah, I finally stumbled across that too.

I don't really want to mess around with creating and copying documents via JavaScript... seems like a headache.

Guess I'll stick with the initial suggestion of scaling:

exportOptions.horizontalScale = 216;
exportOptions.verticalScale = 216;
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 18, 2011 Apr 18, 2011

It appears as though the DocumentRasterResolution constant is only referenced by the DocumentPreset object.

The DocumentPreset object appears to be used when you attempt to create a document with script:

app.documents.addDocument( DocumentPreset );

So, I suppose in theory I could recreate the document entirely with script and then reset the preset raster resolution:

DocumentPreset.rasterResolution = DocumentRasterResolution;

Buuuuuut, screw that.

Scaling it is... apparently.

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