private String useImageVariables(String s) {
		int n = view.getNumberOfInstances(ImageComponent.class);
		if (n <= 0)
			return s;
		int lb = s.indexOf("%image[");
		int rb = s.indexOf("].", lb);
		int lb0 = -1;
		String v;
		int i;
		ImageComponent ic;
		while (lb != -1 && rb != -1) {
			v = s.substring(lb + 7, rb);
			double x = parseMathExpression(v);
			if (Double.isNaN(x))
				break;
			i = (int) Math.round(x);
			if (i < 0 || i >= n) {
				out(ScriptEvent.FAILED, "Image " + i + " does not exist.");
				break;
			}
			v = escapeMetaCharacters(v);
			ic = view.getImage(i);
			s = replaceAll(s, "%image\\[" + v + "\\]\\.x", ic.getRx() * R_CONVERTER);
			s = replaceAll(s, "%image\\[" + v + "\\]\\.y", ic.getRy() * R_CONVERTER);
			s = replaceAll(s, "%image\\[" + v + "\\]\\.angle", Math.toDegrees(ic.getAngle()));
			s = replaceAll(s, "%image\\[" + v + "\\]\\.width", ic.getWidth() * R_CONVERTER);
			s = replaceAll(s, "%image\\[" + v + "\\]\\.height", ic.getHeight() * R_CONVERTER);
			s = replaceAll(s, "%image\\[" + v + "\\]\\.custom", ic.custom);
			lb0 = lb;
			lb = s.indexOf("%image[");
			if (lb0 == lb) // infinite loop
				break;
			rb = s.indexOf("].", lb);
		}
		return s;
	}