I have no skill to create a node but I like to make a little contribute. I was thinking to a node to resize the image but mantaining proportions and selecting a target. Example I have an image of 512x600, I need a side of 1024. I have two tools: upscale image and putting 1024x1200 or upscale image by putting 2x. Both tools need a manual calc, first one needs an additional calc. With upscale models the calc is variable. Some models are upscaling 2x, some 4x... they aren't equal and the result is different. Writing a code that makes the calc automatically can makes the things easier. I don't know the logic of upscale nodes so I write two codes:
from PIL import Image
im = Image.open(#image to resize)
w, h = im.size
target #(w or h) # <- seeable in the node as input
target_size=1024 # <- seeable in the node as input
upscale_factor= (target_size/target)
w1= w upscale_factor
h1= h upscale_factor
if upscale image node needs x_upscale: (logic similar to 'upscale image by' node)
from PIL import Image
im = Image.open(#image to resize)
x_upscale=4 # 4 is an example, select upscale multiplier of the model <- seeable in the node as input
w, h = im.size
target #(w or h) #<- seeable in the node as input
target_size=1024 #<- seeable in the node as input
upscale_factor= (target_size/target)/x_upscale #(pratically scale by input)
x_upscale select upscale multiplier of the model, example remacri is x4, in the input need to be set to 4
target_size is the measurement of the side taken in reference. example of width of 512, i select target w and target_size of 1024, automatically height is calculated as 1200. x_upscale is set manually, can be automatically putting a name list of known upscale models or calling a queue in the code putting a very little empty latent image, passing it to upscale model and calculating the size of the resulting image, then dividing the size with that one of the empty latent image. But it's complicated, it's easier to put it manually
I have no skill to create a node but I like to make a little contribute. I was thinking to a node to resize the image but mantaining proportions and selecting a target. Example I have an image of 512x600, I need a side of 1024. I have two tools: upscale image and putting 1024x1200 or upscale image by putting 2x. Both tools need a manual calc, first one needs an additional calc. With upscale models the calc is variable. Some models are upscaling 2x, some 4x... they aren't equal and the result is different. Writing a code that makes the calc automatically can makes the things easier. I don't know the logic of upscale nodes so I write two codes:
from PIL import Image
im = Image.open(#image to resize) w, h = im.size target #(w or h) # <- seeable in the node as input target_size=1024 # <- seeable in the node as input upscale_factor= (target_size/target) w1= w upscale_factor h1= h upscale_factor
if upscale image node needs x_upscale: (logic similar to 'upscale image by' node)
from PIL import Image
im = Image.open(#image to resize) x_upscale=4 # 4 is an example, select upscale multiplier of the model <- seeable in the node as input w, h = im.size target #(w or h) #<- seeable in the node as input target_size=1024 #<- seeable in the node as input upscale_factor= (target_size/target)/x_upscale #(pratically scale by input)
x_upscale select upscale multiplier of the model, example remacri is x4, in the input need to be set to 4 target_size is the measurement of the side taken in reference. example of width of 512, i select target w and target_size of 1024, automatically height is calculated as 1200. x_upscale is set manually, can be automatically putting a name list of known upscale models or calling a queue in the code putting a very little empty latent image, passing it to upscale model and calculating the size of the resulting image, then dividing the size with that one of the empty latent image. But it's complicated, it's easier to put it manually