Vinny Glennon
Vinny Glennon

Reputation: 149

How can I programmatically tell if an eps file has a gradient?

I imagine imagemagick or likewise could achieve this, but have not yet found a command to tell me.

Upvotes: 0

Views: 82

Answers (1)

emcconville
emcconville

Reputation: 24419

No. Or at least, not reliably. The language doesn't have a `gradient' directive that can be quickly identified.

From MJ Rutter's - EPS: a Programming Language

There are several ways of creating a gradient fill background: Gradient Fills

  1. Draw filled rectangle covering whole area, then a rectangle marginally smaller covering almost whole area and of next shade, etc.
  2. Draw abutting filled rectangles.
  3. Draw slightly overlapping filled rectangles.
  4. Scale a 1D bitmap appropriately.

Authors of EPS files would leverage old-school techniques, and I wouldn't be surprised if various companies / vendors have implemented unique methods of applying gradients.

You can always render the EPS file into a raster image, than use to determine if a gradient slop exists. See this question for an idea.

Upvotes: 1

Related Questions