} else if (imageHeight > y) {
                imageWidth = imageWidth * (y / imageHeight);
                imageHeight = y;
                if (imageWidth > x) {
                    imageHeight = imageHeight * (x / imageWidth);