Skip navigation
Currently Being Moderated

[Javascript] How to trim/crop an image for export

Jul 2, 2012 7:12 PM

Tags: #javascript #illustrator_cs5

Hey folks,


Got lucky with an answer the first time, thought I'd try again.  In Illustrator CS5+, I'm looping through the objects in a document, exporting each of them to an image using exportArtBoardasImage().  They need to be trimmed afterwards, as they generally have a tonne of whitespace.  Normally, I run an ImageMagick shell script (mogrify -trim).  It'd be awesome if I could reproduce this functionality from within illustrator.  I've seen people handle this by copy-and-pasting each object into a new file, sizing the artboard to that object, exporting, then closing the file.  I'd rather not do this, as it's *way* too slow.  Any other suggestions?





  • Currently Being Moderated
    Jul 2, 2012 8:56 PM   in reply to kimberleyhansen

    - loop thru selected objects and push the objects into an array

    - set selection to null to deselect everything

    - do your thing

    - loop thru your object's array and restore selection

    Mark as:
  • Currently Being Moderated
    Jul 3, 2012 4:43 AM   in reply to kimberleyhansen

    "I have everything selected…" It is better not to use selections where possible… If you want everything just loop pageItems? And to the OP you can loop almost anything chaning the artboard as you go… No need for ImageMagik

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points