Scale Factor is 1 and I do not understand

The code below was returning 1 (1,) and I do not understand why. I changed < to > to get the same value. Different images were tested.

Then, I searched in an old project what code I wrote to do the job and it is now OK.

But I still not get why I do not have the correct scale factor.

Dim Scale_Factor As Double

AnImage = Picture.Open(myChild_FI)

If AnImage.Width < AnImage.Height Then
Scale_Factor = AnImage.Width / AnImage.Height
Else
Scale_Factor = AnImage.Height / AnImage.Width
End If

The obvious answer would be that the image is square in shape.
We can’t see your images…

1 Like

You may are right… I had a macOS Icon in the test images…

I will look as soon as I will be back home…

That may explain the other code (who do not have troubles with squared images…):


Dim ratio As Double = min(maxHeight / p.height, maxWidth / p.width)

where MaxH/maxW are the sizes of the Canvas, p.h / p.w the ,size of the picture to resize…
That works fine with squared, lanscape and portrait pictures…

Thank you Jeff.

Example that fits:

Nota:
a simple example of what I want to do. The final project is far away…

You are correct.

Once at home, I checked and the explanation is… I set a default scale value AND changed the image from a square to a larger and the same with a 90° rotation !

Silly…

And I am quite sure I walked in the same street some times ago with the other project and then changed the code to the one I use now.