How to get the path coordinates of a shape for use with image-maps?
Asked Answered
E

6

20

I am creating an image map using ImageMapster from here.

I have created a photoshop image with several images that I have cut out from the original photographs. Each image is on a separate layer.

Now, I need to get the path coordinates of each object, and I don't want to hover over every corner and manually write down each coordinate.

Is there an automated way to get this path?

Maybe there is some application or web service whence I can send my image and get the path in return?

I have tried exporting each layer separately and then importing them into illustrator and vectorizing the shape (it keeps the shape in its original position), but I can't figure out how to get the coordinate path as text. I can export it to svg, but that isn't the same simple code needed for the css image map.

Eastman answered 12/12, 2012 at 18:8 Comment(0)
E
34

Ah! After googling image-map, much thanks to Sven for the idea (he got my +1), I found this thread here on Stack Overflow.

So here is my process.

  1. Prepare the image in Photoshop with each object on a separate layer with a transparent background (this will make it easy for you when you do the tracing).
  2. Save your photoshop file.
  3. Open the Photoshop file in Illustrator using File...Open (works in CS4 and CS5) and make sure to allow the option to import Photoshop's layers as separate objects. After you open the file, make sure NOT to move any of the objects around - you need them to be in the exact same place as they were in the photoshop file so they can superimpose each other when rendered to the imagemap.
  4. Use the Live Trace with custom settings. Use the black & white mode with the threshold all the up (255). This will produce a black silhouette of the shape. (You can also use "ignore white"). Push the Trace button. If you have many layers, you can save this new tracing pattern as a preset - I called mine, Silhouette. Now, I just click on a layer and choose Silhouette from the tracing buttons' dropdown menu.Adobe Illustrator Tracing Settings
  5. Expand the shape and make sure it consists of only a single flat shape:
    • you can use the blob brush in illustrator to blacken over any unwanted white areas
    • no groups
    • no compound shapes (or it won't work) - which means you can't create cutouts.
    • You can tell the shapes are right when you click on them - you should be able to see the path itself with no "other" shapes involved (perhaps the blob brush additions) - just a single path. An easy method is this:
      • select the shape
      • ungroup if necessary
      • release compound path
      • unite (shape mode merges all shapes into one)
    • Don't crop your image - you want your shape to be in the same place in the image's area as in your original photoshop image.
    • Don't join all the shapes together, either.
    • The shapes should all be individual whole shapes, all in their original locations, each on a separate layer.
  6. Now, open Illustrator's Attributes panel, and make sure to "show options".
  7. Select your shape and in the "Attributes" panel, switch the "Image Map" combo box from None to Polygon. Make sure to add a url (it doesn't matter what you put; you can change it later - I just put "#" and the name of the shape so I can tell which one it belongs to in the image map code) enter image description here
  8. Do this for each of the objects.
  9. Now, in the File menu, go to "Save for Web and Devices". Skip all the settings here and just push "Save".
  10. In the "Save As" (the title of the window is "Save Optimized As") dialogue box, use "Save As type:" and select HTML Only(*.html) if you just want the code, or HTML and Images if you want the sillouhuette, too (they will appear in a folder called "images") - and note your save location. enter image description here
  11. Now go open that html file in notepad!
  12. Voila! All the shapes will be rendered for you as a pre-made image-map - points path and even html code. Here is what it looks like when you open in notepad the html file you just created: enter image description here For this demo, I chose a particularly complicated image - one which you would never want to estimate by hand, nor have to do twice!

Don't forget to place the actual image file somewhere in your site's images folder. You can save the psd file for later and add more "stuff" if you want, and repeat the process.

I was able to create the image map this way for my photoshop picture in just a brief couple of minutes. After you do it once, it gets easier for next time.

Eastman answered 12/12, 2012 at 20:10 Comment(7)
I skipped over most of the photoshop stuff b/c I already had my icon in illustrator but steps 6 and 7 were the main ones I had to follow. However, for CS6, it seems that there is no "save for web device" just "save for web" and with that, no option to save the type as "html and images." There is a "preview" button on the same screen as the "save" button and that will give you the html markup to use in the browser which seemed to work for my case (using custom icon in google maps). great write up!Cosmism
@Cosmism If you click preview which is in the bottom left of the "save for web" dialog it takes you to a html page where you can copy/paste your image areas.Linnell
Thank you very much for this great solution. I tried this in Adobe CC, and had to select "Ungroup" on my trace before assigning URL to the image map. I don't understand it enough to know why, but might help someone. Another change I had to make was save my psd with 72ppi, to prevent the image from being resized when opened in Illustrator. It has to match the default ppi of Illustrator.Undying
Cool... this is very practical info for using image mapsterSeasonseasonable
@MikePennington Thanks! I am quite pleased to have posted this little tutorial. You can see my example in action here: shoppe.sspxusa.orgEastman
@BGM: a big fat +1 for the great tut! I however stumble across this problem: I created a PSD with separate layers which all have a gray filling. Then when I open it in Illustrator it has a rectangle around it, and not the outline of the filling. So when I save the HTML, a rect-shape is exported and not a polygon (I did select the polygon option in the attribute window). Any thought on how to solve it?Shovelnose
The gray filling shouldn't matter - you are going to TRACE the object in Illustrator, anyway. However, you might be tracing the wrong layer.Eastman
T
7

This has been bugging me for so long and I don't have Illustrator to be able to use the solution proposed by BGM, that I created my own Photoshop addon.

You can get it here: https://creative.adobe.com/addons/products/2389

It writes all your paths' points' coordinates to a text file. Should work for CS6 and above.

The way I use it is I create a marquee, right click -> make work path, rename my path, [repeat], then just export coords via my addon.

If anyone's interested in the scripts behind it, you can have a look here: http://pastebin.com/8ugcAV3j

In case you make any improvements, please post them here so that other people may use them as well.

Hope this helps someone.

EDIT: added link to source script (was only in comments before)

Trustee answered 9/6, 2014 at 11:54 Comment(7)
Say, that looks interesting! Can you allow it to work for CS5? I'd like to try it out. It looks like I would need Adobe Configurator for CS6 in order to download it. Do you have a direct link?Eastman
I don't know how to make a "plugin" for CS5, because Adobe Configurator doesn't allow it, but I can give you the JavaScript it uses. Try saving this pastebin.com/8ugcAV3j as pathToCoords.jsx and then running it in Ps (in CS6 it's under File->Scripts->Browse..). Let me know if it works in CS5 and/or if you find a way to somehow "bookmark" the script so you don't have to browse for it each time.Owensby
Thanks for the js; in fact, that looks like a regular extendscript script. I'll try it and post back here.Eastman
+1 It really helped me as i dont have illustrator. Many thanks :)Curl
You should add the JS to the answer, it's very interesting to see the logic behind also :)Chandachandal
@MichaelKonečný just found this, and it's great, although it looks like your script file does not mark whether a point is a plain vertex or whether it's a bezier control point, making it very hard to use the resulting coordinatesCallisthenics
Sounds good but not being maintained so doesn't work with current versions of PSRora
T
3

I used this to find the co-ordinates of the outline of a shape to make image hotspots for links in dreamweaver. If you have something else in mind, then you'll have to ignore some of it. This works on a single layer so you may want to make a "flattened copy first", but I don't see why it wouldn't work on a multi layered image.

Use wand to highlight area you want. This will be different for different images. Right click and hit Make Work Path. Use a suitable tollerance which is found by trial and error. I just use the most sensitive. Do this for all areas in all of your images creating separate paths for each. Click edit then export paths to illustrator and save file in sensible place. Open the saved file in word. Ignore the bumf the the top and use replace to remove ALL LETTERS. Don’t worry about the paragraph characters. Note that all of the work paths are exported in the same file separated by a blank line so must copied and pasted separately to be used for each hotspot.

After inserting your image. Start making a map in dreamweaver with a couple of co-ordinates then simply replace these in the with information from the illustrator file for each of the map areas to be produced.

Tryptophan answered 6/8, 2013 at 15:25 Comment(0)
A
2

I add my updated answer I had to find since adobe has eliminated HTML output in many instances, I work mostly with photoshop (CS4) and this is a perfect solution:

1) download following file: https://github.com/andyhawkes/ps-paths-to-imagemap

2) open your image in photoshop and select the form with the magic wand

3) right click and select 'make work path' (the lesser the px, to more accurate)

4) go to File -> Scripts -> Browse ... and select the script from the first step

that's it !! this script will open your texteditor with the coordinates ...

Accumbent answered 18/4, 2017 at 5:32 Comment(0)
L
0

Something like this may be useful;

http://code.google.com/p/imagemap/

Copy your image into position, then plot.

Lorsung answered 25/8, 2017 at 9:18 Comment(0)
O
-2

creating an image map is really simple. First we need to look at the syntax of the code Let's create a div.If we want to position it at the right side of our page,we can just begin by writing

<div align="right">

After that, we import the image that we are gonna map.

<img src="" alt="" width="" height="" usemap="#nameofmap" />

Now we have to define the map structure.First lets assume that you want a rectangular portion of an image to act like a hyperlink.

<map name="nameofmap">
<area href="wherever I wanna take that.com" alt="" title="" 
shape=rect coords="A,B,C,D"></map>

Now we close the div.

</div>

If the shape is circular,we use the syntax shape=circle coords="x,y,radius"

If shape is polygonal, we use **shape=poly coords="a,b,c,d,e,f,gh"

Now comes the big part:How to find the image map coords. Very simple.Go to http://www.image-maps.com Browse your image file,click "Start Mapping your image",then you proceed, and then on the next page,click "Import Old mapping Code" on the right.then you get the coords.

After that, you can use FIREBUG to change the coords according to your specifications,because image-maps only hyperlinks the whole image,so use firebug to change the coords and adjust according to your requirements.

Have fun.

Oao answered 29/7, 2013 at 14:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.