Error - Missing “)”

Hello. I am newbie in programming. I’m trying to learn to use it in my work in photography and visual arts. I’m trying to run a code but it always gives Error - Missing “)” in the parts that I’ll put below and I don’t know how to fix it.
Thanks a lot if anyone can answer me.

float ratio = renderWidth / (float)renderHeight;
if (ratio > 1) {
outWidth = 1024;

After this you need a }

1 Like

Hi! Thanks a lot for the answer, but unfortunately it didn’t work :frowning:

1 Like

What error came up? Maybe provide the full code so we can check …

Cheers
— mnse

I’m trying to render the result I got after applying a generative code on a photograph. I would like to get a jpg or png image with good quality and this is the code I am trying to use:

int outWidth, outHeight;

float ratio = renderWidth / (float)renderHeight;
if (ratio > 1) {
outWidth = 1024;
outHeight = (int)(outWidth / ratio);
} else {
outHeight = 1024;
outWidth = (int)(outHeight * ratio);
}

background(192);
image(render,
(1024 - outWidth) / 2, (1024 - outHeight) / 2,
outWidth, outHeight);

1 Like

Do you load and declare the image?

This works:



PImage render=loadImage("c1.jpg"); 

int renderWidth=0, renderHeight=0; 
int outWidth, outHeight;

float ratio = renderWidth / (float)renderHeight;
if (ratio > 1) {
  outWidth = 1024;
  outHeight = (int)(outWidth / ratio);
} else {
  outHeight = 1024;
  outWidth = (int)(outHeight * ratio);
}

background(192);
image(render, 
  (1024 - outWidth) / 2, (1024 - outHeight) / 2, 
  outWidth, outHeight);
//