in assets/support/faq/docbook-xsl/extensions/xalan2/com/nwalsh/xalan/ImageIntrinsics.java [44:107]
public ImageIntrinsics(ExpressionContext context, String imageFn) {
image = Toolkit.getDefaultToolkit().getImage (imageFn);
width = image.getWidth(this);
while (!imageFailed && (width == -1 || depth == -1)) {
try {
java.lang.Thread.currentThread().sleep(50);
} catch (Exception e) {
// nop;
}
width = image.getWidth(this);
depth = image.getHeight(this);
}
if (imageFailed) {
// Maybe it's an EPS or PDF?
// FIXME: this code is crude
BufferedReader ir = null;
String line = null;
int lineLimit = 100;
try {
ir = new BufferedReader(new FileReader(new File(imageFn)));
line = ir.readLine();
if (line != null && line.startsWith("%PDF-")) {
// We've got a PDF!
while (lineLimit > 0 && line != null) {
lineLimit--;
if (line.startsWith("/CropBox [")) {
line = line.substring(10);
if (line.indexOf("]") >= 0) {
line = line.substring(0, line.indexOf("]"));
}
parseBox(line);
lineLimit = 0;
}
line = ir.readLine();
}
} else if (line != null && line.startsWith("%!") && line.indexOf(" EPSF-") > 0) {
// We've got an EPS!
while (lineLimit > 0 && line != null) {
lineLimit--;
if (line.startsWith("%%BoundingBox: ")) {
line = line.substring(15);
parseBox(line);
lineLimit = 0;
}
line = ir.readLine();
}
}
} catch (Exception e) {
// nop;
}
if (ir != null) {
try {
ir.close();
} catch (Exception e) {
// nop;
}
}
}
}