Sg2.9
Vector Pixels
Recent RSS
Creator:  Graham van de Ruit
Date:  18. February 2013, 13:41

This script uses the selected paths to create a vector version of the selected raster images. It is similar to the Object Raster script from the examples, but there are some important differences:

  • The paths are NOT scaled to obtain different grayscale values. Instead the path with the closest matching gray value is used for each area of the raster image. It is VERY IMPORTANT, therefore, to use multiple paths with different areas. The more paths you use and the greater their variation in tone, the more accurately the raster image will be recreated.
  • To scale the paths in the final image (ie change the resolution) just scale the sample paths. They will be used as is, with no change in size or style.
  • The script uses any paths you select, so you can use simple shapes such as circles (remembering to select mutiple circles at different sizes), custom shapes such as hearts, or even letters or more complex shapes. To use letters, create a text box, type each character or glyph you want to be included, then expand the text box to convert the letters to outlines. Use this group as your sample paths.

Note that the paths are all centered on their grid squares when used in the image, so letters will NOT maintain their baselines. If anyone is able to adapt it to allow for a standard baseline I think it might be a valuable addition.

You can get particularly rich images by using negative values for the grid gutters and applying transparency and blend modes to your sample paths. Inverting the tones is useful if you want your shapes to be filled with a light colour and set on a dark background

In most of the sample images I have included my sample paths to the bottom left of the final image.

Feel free to post queries or report bugs. I’d love to hear if you find it useful.

Re: Vector Pixels
From:  Jim
Date:  25. July 2013, 13:31

Here is a little more info on my problem.

The script seems to be working but it just creates a vector square of black at the top left corner of the image and fails (at line 109) to do anymore? See attached image.

Is this a known issue? I cant think what is going wrong. Image is embedded, circles are compound paths, expanded...

Any ideas?

Thanks in advance.

Re: Vector Pixels
From:  pqbd
Date:  27. July 2013, 18:56

Can you supply the file that is giving you trouble?

Re: Vector Pixels
From:  Jim
Date:  31. July 2013, 12:10

Here is a link to the ai file. https://www.dropbox.com/s/2rfyg12uknyajiw/Abel.ai
Graham has been helping out but no success as of yet.

I'm using illustrator CS5 v15.0.0 with Scriptographer 2.8.052 and Java 1.6.0_51 — all other scripts run fine.

Very strange, Hope someone can figure this out?

Re: Vector Pixels
From:  pqbd
Date:  1. August 2013, 21:44

Hmm. I don't get any errors in the console like you stated, but there is an issue with the script; it doesn't seem to account for paths with negative areas.

Does it work if you change line 95 from:

colours.push(paths[i].getCompoundArea());

to:

colours.push(Math.abs(paths[i].getCompoundArea()));

Re: Vector Pixels
From:  Jim
Date:  5. August 2013, 13:18

Line 95 already reads:

colours.push(Math.abs(paths[i].getCompoundArea()));

Do you mean change this to:

colours.push(paths[i].getCompoundArea());

I tried that. Nothing. Still the same issue.

Any ideas? This is really frustrating. I just can't work out what the problem is.
I'm sure it's something really simple.

Re: Vector Pixels
From:  Jim
Date:  5. August 2013, 13:23

Error is still:

TypeError: Cannot call method "convert" of null
at scripts/rasters/Vector Pixels.js:109

Re: Vector Pixels
Date:  5. August 2013, 13:38

Hi Jim

That was the change that I made in the last version I sent you, so other users will still have the one without the Math.abs in there.

I was hoping that would fix it. It’s difficult to see what the problem could be as it seems to be working fine for me and other users. I’ll keep looking and see what I can figure out.

Of course, other users’ input will also be welcomed.

Re: Vector Pixels
From:  Jim
Date:  5. August 2013, 14:00

Thanks Graham,
Could it be my version of Illustrator? or Java?

Re: Vector Pixels
From:  Jim
Date:  5. August 2013, 15:03

Thanks for all your help everyone. Somehow (and i don't know why) it's now working!

I was sure I had the latest version of scriptographer, but perhaps not as after a reinstall it all works fine.

Thanks for your help.

Re: Vector Pixels
From:  ars
Date:  18. August 2014, 11:01

Thanx for great tool, i found it very useful!

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19