YOUR ACCOUNT

Login or Register to post new topics or replies
BillB
Posts: 10
Hi, I'm a little challenged, can't figure out how to convert floats and integers back and forth easily. Working on automatic image size conversion to good sizes...
  Details E-Mail
yojoza
Posts: 2
I was looking for this too. I wanted to ensure that image size would automatically be converted to a maximum height or width of (say) 768. My workaround is this.

The "Resize" node, when set to proportional, only needs the width argument. It'll calculate the proportional value for height itself. So you can simply enter a value of "1" for height. When the height is the larger of the two, rotate the image to make it the width then rotate it back. You can then set the Resize width argument to a target number (e.g., 768).

This way the float operations are handled internally by Resize.

  Details E-Mail
BillB
Posts: 10
Thanks yojoza, I'll try this. I like the idea of rotating the image.
I've been resizing to 736 max dimension since I often crash on anything bigger. Even at 736 if the other dimension is too large, somewhere above 544, it will crash.
  Details E-Mail
Cate Blanchett
Cate Blanchett

Posts: 11
Converting between floats and integers in Python is straightforward. Use int() to convert a float to an integer (truncating the decimal) and float() to convert an integer to a float. For automatic image size conversion, you can round or floor/ceil the float values to maintain the best aspect ratios before converting to integers.
  Details E-Mail
yojoza
Posts: 2
Converting between floats and integers in any programming language is straightforward. But that doesn't explain how to do so using Ultraforge's node-based programming. Which nodes, specifically, allow conversion between integers and floats within Ultraforge?

Here's my original problem in a nutshell. (The workaround I posted above works to resolve this but it's not elegant.)

- Ultraforge works well for me with SD 1.5 Image-to-Image as long as the assets are 768x768 or smaller.
- I don't want the headache of converting assets in Photoshop to fit these dimensions
- I want to convert directly in Ultraforge so that...
...square images are resized to 768 x 768
...rectangular images with Width > Height are resized to 768 x Y
...rectangular images with Height > Width are resides to Y x 768

However:

- The GetHeight and GetWidth nodes only output integers
- When Divide node gets two integers as input, the output can be an integer. (The divide node refuses to let me change the output type.)

As far as I can tell, there is no way to force the output type for the Divide node. There's also apparently no way to convert the GetHeight and GetWidth values to float and no way to convert floats to integers. Of course, I could be missing something. With no manual or tutorials, I'm in the dark. I've been able to get by so far with a passable understanding of functional programming/lambda calculus.
  Details E-Mail
Java10
Posts: 16
Quote
With no manual or tutorials, I'm in the dark.


Hi Yojoza,

OK, we are no two smile:)

I think you are already much further ahead than me - have you found a node that generates a random number e.g. for the parameter "Seed"?

I would like to help you with your problem, but you are way ahead of me.
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,531 Posts
+39 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

18 unregistered users.