모든 이미지 유형에 대해 문서를 스캔하고 흑백으로 변환 한 다음 흑백 이미지를 새 폴더로 내 보내는 스크립트가 있습니다.
InDesign CS5/Script : TIFF 및 PNG 이미지를 '흑백으로 변환 할 수 있습니까?
그것은 InDesign에서 이러한 이미지 파일 형식을 보냅니다 것처럼 보인다
JPEG, TIFF, and PNG
(가
하지 수출 GIF 파일을한다).
그러나 (이 하지만,는 JPEG 파일이 속성을 가지고있다) InDesign에서 TIFF 및 PNG 파일에 대한
ColorSpace.GRAY
또는
ColorSpaceEnum.GRAY
특성이없는 것 같다.
그래서, 인디자인의 수정 ExtendScript 흑백 에 TIFF 및 PNG 파일을 변환하는 방법은 무엇입니까?
이 아니고 인 경우 이러한 파일 형식에 대해 흑백 변환을 수행하지 않는 이유는 무엇입니까? 여기
가 현재로서는 유일한 흑백 JPEG 파일을 내보내는 것을, 내 코드입니다 : 그래서
var document = app.activeDocument;
var newFolder = createFolder(document); // if subdirectory DNE, create this folder with the function below
saveAllImages(document, newFolder); // with the function below
function createFolder(doc)
{
try
{
/*
* type-casting the filePath property (of type object) into a String type;
* must be a String type to concatenate with the subdirectory variable (also of type String)
*/
var docPath = String(doc.filePath);
var subdirectory = "/BLACK AND WHITE IMAGES";
}
catch(e)
{
alert(e.message);
exit();
}
var imagesFolder = docPath + subdirectory; // concatenating the two variables
if(!Folder(imagesFolder).exists)
{
Folder(imagesFolder).create();
}
return imagesFolder; // for instantiation outside of this function
} // end of function createFolder
function saveAllImages(doc, folder)
{
var imgs = doc.allGraphics;
var fileName = "";
var img = "";
var imgType = "";
for(var i = 0; i < imgs.length; i++)
{
if(imgs[i].itemLink != null)
{
fileName = imgs[i].itemLink.name;
img = new File(folder + "/" + fileName); // each image instantiated here
imgType = imgs[i].imageTypeName; // image type is determined here (.tif, .jpg, .png, etc..)
alert("This is a " + imgType + " file.");
/*
* array for image options, instantiated from the function below;
* options[0] is the "MAXIMUM" image quality property, &
* options[1] is the "GRAY" image conversion property;
*/
var options = convertToBlackAndWhite(imgType);
// each image exported to the new folder here, by file type
switch(imgType)
{
case "GIF":
alert("This script cannot convert and export the GIF file:\n\t" + fileName + " !");
break;
case "TIFF":
case "EPS":
case "JPG":
options[0]; // maximum image quality
options[1]; // black & white conversion
imgs[i].exportFile(ExportFormat.JPG, img, false);
break;
case "PNG":
options[0]; // maximum image quality
options[1]; // black & white conversion
imgs[i].exportFile(ExportFormat.PNG_TYPE, img, false);
break;
default:
alert("\tUnlisted image type: " + imgType + "!\nAdd this type to the switch statement.");
break;
} // end of switch statement
} // end of if statement
} // end of for loop
} // end of function saveAllImages
function convertToBlackAndWhite(fileType)
{
// array for image-quality and color-conversion values
var settings = [];
// each image exported to the new folder here, by file type
switch(fileType)
{
case "TIFF":
case "PNG":
case "EPS":
case "JPG":
settings[0] = "app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM"; // maximum image quality
settings[1] = "app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.GRAY"; // black & white conversion
break;
default:
break;
} // end of switch statement
return settings; // for instantiation outside of this function
} // end of function convertToBlackAndWhite
흠, 어쨌든 Photoshop에서 파일 서식을 지정하는 것이 더 바람직 할 수 있으므로 'BridgeTalk'개체를 사용하고 있습니다. 여기서는 좋은 참조를 발견했습니다. http : //forums.adobe. co.kr/message/3334670 # 3334670). @Loic! 감사합니다. 내가 알아 냈을 때 내 코드를 게시 할 것이다 ... –