简体   繁体   English

在 Indesign 框架内处理图像

[英]Manipulating image within Indesign frame

I am currently trying to figure out how to change the color of a bitmapped image within indesign using basil.js.我目前正在尝试弄清楚如何使用 basil.js 在 indesign 中更改位图图像的颜色。 Ideally I would like to place the image and use some sort fo post styling to change the color.理想情况下,我想放置图像并使用某种帖子样式来更改颜色。

var myImage = image('image_0009_10.psd', 0, 0, width, height);
property(myImage, "fillColor", "RISOBlue");

Right now I am using fillColor but that only changes the color of the frame that the bitmap live within.现在我正在使用 fillColor 但这只会改变位图所在帧的颜色。 Anyone got any ideas as to how to edit the contents of a graphic frame?有人对如何编辑图形框架的内容有任何想法吗? Specifically a bitmap?具体是位图?

fabianmoronzirfas is correct that you have to target the graphic of the image frame, I just want to suggest a slightly different syntax, which is a bit more basil-like to achieve the same thing: fabianmoronzirfas 是正确的,你必须定位图像帧的图形,我只想建议一个稍微不同的语法,它更像 basil 来实现同样的事情:

// @include ~/Documents/basiljs/basil.js

function draw() {

  var myImage = image('~/Desktop/someImage.psd', 0, 0);
  var myGraphics = graphics(myImage);
  property(myGraphics[0], 'fillColor', color(0, 0, 255));

}

Note the use of the graphics() function to get the actual graphics within an image rectangle.请注意使用graphics()函数来获取图像矩形内的实际图形。

graphics() is perfect for this (as @mdomino mentioned) – but can also just grab that property of the image: graphics()非常适合这个(正如@mdomino 提到的)——但也可以抓住图像的那个属性:

var myImage = image('image_0009_10.psd', 0, 0, width, height);
property(myImage.graphics[0], "fillColor", "RISOBlue");

Running inspect(myImage) will give a long laundry list of available properties .运行inspect(myImage)将给出一长串可用属性的清单。

Welcome to STO 👋 🎉 🎈欢迎来到 STO 👋 🎉 🎈

You are currently setting the fillColor for the Rectangle that contains the image.您当前正在为包含图像的Rectangle设置fillColor You will have to select the image explicitly since it is a child object of that Rectangle .您必须明确选择图像,因为它是该Rectangle的子对象。 See:看:

The code below is tested with InDesign 14.0.1 and the current Basil.js Develop version 2.0.0-beta下面的代码使用 InDesign 14.0.1 和当前的Basil.js Develop 版本 2.0.0-beta 进行了测试


// @include "./basil.js"
function setup() {
  var doc = app.activeDocument;
  var imageFile = file(new File($.fileName).parent + "/img.bmp");
  var img = image(imageFile, 0, 0, 100, 100);
  img.images[0].fillColor = doc.swatches[4];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM