#target photoshop
// Save the current unit preferences (optional)
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
// Set units to PIXELS
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
// Use the top-most document
var doc = app.activeDocument;
var coords = doc.selection.bounds;
// Write coords to textfile on the desktop. Thanks krasatos
var f = File( '~/Desktop/coords.txt' );
f.open( 'w' );
f.write( coords );
f.close();
// Reset to previous unit prefs (optional)
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
#target photoshop
// Save the current unit preferences (optional)
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
// Set units to PIXELS
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
// Use the top-most document
var doc = app.activeDocument;
// Turn the selection into a work path and give it reference
doc.selection.makeWorkPath();
var wPath = doc.pathItems['Work Path'];
// This will be a string with the final output coordinates
var coords = '';
// Loop through all path points and add their anchor coordinates to the output text
for (var i=0; i<wPath.subPathItems[0].pathPoints.length; i++) {
coords += wPath.subPathItems[0].pathPoints[i].anchor + "\n";
}
// Write coords to textfile on the desktop. Thanks krasatos
var f = File( '~/Desktop/coords.txt' );
f.open( 'w' );
f.write( coords );
f.close();
// Remove the work path
wPath.remove();
// Reset to previous unit prefs (optional)
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
I'll tell you how to do it with JavaScript, since this is a programming Q/A site.
To get the rectangular coordinates of the selection bounds is easiest:
#target photoshop
// Save the current unit preferences (optional)
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
// Set units to PIXELS
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
// Use the top-most document
var doc = app.activeDocument;
var coords = doc.selection.bounds;
// Write coords to textfile on the desktop. Thanks krasatos
var f = File( '~/Desktop/coords.txt' );
f.open( 'w' );
f.write( coords );
f.close();
// Reset to previous unit prefs (optional)
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
This will give the rectangular bounds (think of the bounding box you see when transforming) of the selection in the current active document. It outputs in the order minX, minY, maxX, maxY. This should be enough info to translate to CSS coordinates.
To get the coordinates of individual polygon points you can make the selection into a path and output each pathPoint.anchor on the path using this script:
#target photoshop
// Save the current unit preferences (optional)
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
// Set units to PIXELS
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
// Use the top-most document
var doc = app.activeDocument;
// Turn the selection into a work path and give it reference
doc.selection.makeWorkPath();
var wPath = doc.pathItems['Work Path'];
// This will be a string with the final output coordinates
var coords = '';
// Loop through all path points and add their anchor coordinates to the output text
for (var i=0; i<wPath.subPathItems[0].pathPoints.length; i++) {
coords += wPath.subPathItems[0].pathPoints[i].anchor + "\n";
}
// Write coords to textfile on the desktop. Thanks krasatos
var f = File( '~/Desktop/coords.txt' );
f.open( 'w' );
f.write( coords );
f.close();
// Remove the work path
wPath.remove();
// Reset to previous unit prefs (optional)
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
Instructions:
-open your map image
-make a selection of the region using your favorite selection tool
-run the script with the extendscript toolkit or by choosing File>Scripts>Browse... and select the .jsx file where the script is saved.
发布评论
评论(2)
ps 中没有任何选项,您必须在 Dreamweaver 中创建坐标。
there isn't any option in ps you have to make coordinates in Dreamweaver.
我将告诉您如何使用 JavaScript 来完成此操作,因为这是一个编程问答网站。
获取选区边界的直角坐标是最简单的:
这将给出当前活动文档中选区的矩形边界(想想转换时看到的边界框)。它按照 minX、minY、maxX、maxY 的顺序输出。这应该足以转换为 CSS 坐标。
要获取各个多边形点的坐标,您可以将选择放入路径中,并使用以下脚本输出路径上的每个 pathPoint.anchor:
说明:
- 打开地图图像
- 使用您最喜欢的选择工具选择区域
- 运行使用 ExtendScript 工具包或选择“文件”>“脚本”>“浏览...”,然后选择保存脚本的 .jsx 文件。
I'll tell you how to do it with JavaScript, since this is a programming Q/A site.
To get the rectangular coordinates of the selection bounds is easiest:
This will give the rectangular bounds (think of the bounding box you see when transforming) of the selection in the current active document. It outputs in the order minX, minY, maxX, maxY. This should be enough info to translate to CSS coordinates.
To get the coordinates of individual polygon points you can make the selection into a path and output each pathPoint.anchor on the path using this script:
Instructions:
-open your map image
-make a selection of the region using your favorite selection tool
-run the script with the extendscript toolkit or by choosing File>Scripts>Browse... and select the .jsx file where the script is saved.