2013-02-22 2 views
2

indesign (CS5)에서 선택한 이미지/그룹의 길이와 너비를 출력하고 .png 파일에 선택 사항을 저장하는 자바 스크립트 애플리케이션을 작성하려고합니다. 문제는 선택 영역의 visibleBounds를 사용하여 생성하는 길이와 너비가 내 보낸 이미지의 길이와 너비와 약간 다릅니다. 보다 구체적으로 이미지 높이가 너비보다 크면 생성 된 높이가 결과 .png의 높이와 같지만 생성 된 너비가 약간 더 작아집니다. 반대로 폭이 더 크면 생성 된 높이가 약간 더 작아집니다. 다음은 함께 작업 한 코드입니다.올바른 길이와 너비를 가져 와서 내보내는 indesign

dest = Folder.selectDialog('Save report'); 
selected = app.activeDocument.selection[0]; 
filer = new File (dest+'/'+'testImage.png'); 
h = selected.visibleBounds[2] - selected.visibleBounds[0]; 
w = selected.visibleBounds[3] - selected.visibleBounds[1]; 
alert('height: '+h+'\nwidth: '+w); 
selected.exportFile(ExportFormat.PNG_FORMAT, filer, false); 

이 문제는 비교적 작은 이미지에서만 발생합니다. 이미지가 작을수록 영향이 클 것 같습니다. 어떤 도움이라도 대단히 감사하겠습니다.

+0

visibleBounds 대신 geometricBounds를 사용해 보았습니까? – fabianmoronzirfas

+0

그래, geometricBounds는 정확한 결과를 제공합니다 :/ –

+0

hm. 스크립트가 사용하는 단위를 설정하려고 시도했을 수 있습니다. http://jongware.mit.edu/idcs5/pc_ViewPreference.html app.activeDocument.viewPreferences.properties = { horizontalMeasurementUnits : MeasurementUnits.MILLIMETERS, 의 verticalMeasurementUnits = MeasurementUnits.MILLIMETERS의 } – fabianmoronzirfas

답변

1

정확히 같은 이미지가 페이지의 위치에 따라 다른 크기로 내보내도이 문제가 발견되었습니다. 문제는 inDesign이 픽셀 대신 최저 수준에서 센티미터 또는 인치를 사용하고 있다는 것입니다.

그러나, 나는 결국이 문제를 해결하기 위해 한 일이 내 보낸 후 InDesign 문서에 이미지를 배치하고 두 값의 확인하기 위해 폭과 높이를 확인하는 것입니다. 이 솔루션은 이미지 크기가 이후에 어떤 것인지 알기 위해서만 유효합니다. 일단으로 내 보내면 명백한 이유없이 크기가 변경되기 때문에 크기를 내 보내기 전에 크기를 알 수 없습니다.

selected.exportFile(ExportFormat.PNG_FORMAT, filer, false); 
//These lines load the image into the document, check the size of the image file previously exported, and writes the correct measure into the XML file 
var imageFile = File(filer); 
var imageGraphic = app.activeDocument.pages.item(0).place(imageFile, null); 
imageGraphicItem = imageGraphic[0]; 
var imageFrame = imageGraphicItem.parent; 
var correctImageWidth = Math.round(imageFrame.visibleBounds[3]-imageFrame.visibleBounds[1]); 
var correctImageHeight = Math.round(imageFrame.visibleBounds[2]-imageFrame.visibleBounds[0]); 
//Do something 
imageGraphicItem.parent.remove(); 

희망 하시겠습니까?