Help, how to make this image convert button

I want to make a image convert button:
If the image is wide > high, execute the command:

Image CONVERT=jpg HERE ADDSUFFIX HEIGHT=363 PRESERVEASPECTRATIO

Otherwise, run the following command:

Image CONVERT=jpg HERE ADDSUFFIX WIDTH=363 PRESERVEASPECTRATIO

Also, I don't want to add a suffix to the converted picture, but I want to add a prefix like "-"
Pls how can I write it, thanks!

If the condition was reversed, it could be done with a simple command, since the image converter will fit the image into the specified width and height if both are given.

But doing the opposite, so the smaller dimension is made a fixed size and the other dimension extends outside the width/height box will probably require a bit of scripting.

If scripting is already being used then it's also an easy way to add the prefix to the filename (via the Image command's AS argument).

We can help with that if needed, although we may be a bit slow for the next couple of weeks.

I'm ashamed, I don't know how to write a script, Can you help me write this script, thank you!

If the image width > height

Image CONVERT=jpg HEIGHT=363 AS=-{file} PRESERVEASPECTRATIO HERE

Else

Image CONVERT=jpg WIDTH=363 AS=-{file} PRESERVEASPECTRATIO HERE

End If