srecord noeq PadImageToAspectRatio(BufferedImage img, Ratio ratio, Color color) > Meta { BufferedImage out; BufferedImage get() { int w = img.getWidth(), h = img.getHeight(); double actualRatio = doubleRatio(w, h); double targetRatio = this.ratio!; int w2 = w, h2 = h; if (targetRatio > actualRatio) // target ratio is wider w2 = iround(h2*targetRatio); else h2 = iround(w2/targetRatio); if (scaffolding()) printVars(+w, +h, +w2, +h2, +actualRatio, +targetRatio, ratio := this.ratio); if (w == w2 && h == h2) ret img; out = newImage(w2, h2, color); drawImageOnImage(img, out, (w2-w)/2, (h2-h)/2); ret out; } }