02-01-2023, 12:19 AM
(This post was last modified: 02-01-2023, 01:08 AM by BaconWizard17.)
(01-31-2023, 09:56 AM)Kevin Wrote: scaleFactor = int(maxSize) / int(currentWidth) is returning zero because you're doing integer arithmetic. You need to make one or both into float values to get a fractional scaleFactor
Code:
> > > int(512) / int(258)
1
> > > int(512) / float(258)
1.9844961240310077
The int() was something that I added later as an attempt to fix the issue, in case the original values were being output as strings. When I first posted my message, I had int() around those values, but later edited it out because the original code just said scaleFactor = maxSize / currentWidth.
I did test with one of the values defined as a float() instead, and it worked. So are the values produced by image.width/image.height strings? Is that why it was originally failing?
Edit: I realized that I can check the documentation for this question, and that that operation produces an integer.
Modder/Skinner at MarvelMods.com using GIMP to create, edit, and export textures and previews more efficiently.
My GIMP scripts hosted on GitHub
My GIMP scripts hosted on GitHub