(define (flonum->fixnum num) (inexact->exact (round num))) (define (image-scale/proportional image max-dimension) ;; Scale the given image keeping width/height proportion and ;; limiting the new values to `max-dimension'. (let* ((w (image-width image)) (h (image-height image)) (w-proportion (/ w max-dimension)) (h-proportion (/ h max-dimension)) (scale-factor (if (> h-proportion w-proportion) h-proportion w-proportion))) (image-scale image (flonum->fixnum (/ w scale-factor)) (flonum->fixnum (/ h scale-factor)))))