Add "Scale To Side Length" Resolution Mode to Image Batch Tool#1359
Add "Scale To Side Length" Resolution Mode to Image Batch Tool#1359GlenCarpenter wants to merge 6 commits intomcmonkeyprojects:masterfrom
Conversation
|
I feel like I should explain the reasoning why this is desired - For most image edit models (like Klein or Qwen Edit), you will get much better results if the input image matches the output resolution. So when using this with the 'Use as image prompt' option, this will set the image prompt to the same size as the output. |
|
Converting to draft as I see there was actually some additional functionality requested:
So I am thinking we can have two sliders:
This would then resize the inputs and then set the output side length accordingly. |
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
| await socket.SendAndReportError($"ImageBatchRun request from {session.User.UserID}, for folder '{input_folder}'", "Image batch needs to supply the images to at least one parameter.", API.WebsocketTimeout); | ||
| return null; | ||
| } | ||
| // In case someone tries to leverage the websocket API directly, not possible from UI |
There was a problem hiding this comment.
this comment shouldn't be here
| } | ||
| Image image = new(File.ReadAllBytes(file), MediaType.GetByExtension(file.AfterLast('.'))); | ||
| ISImage imgData = image.ToIS; | ||
| // Check EXIF to make sure we have the correct orientation |
There was a problem hiding this comment.
again, comment should be here
| Image image = new(File.ReadAllBytes(file), MediaType.GetByExtension(file.AfterLast('.'))); | ||
| ISImage imgData = image.ToIS; | ||
| // Check EXIF to make sure we have the correct orientation | ||
| if (imgData.Metadata?.ExifProfile?.TryGetValue(ExifTag.Orientation, out IExifValue<ushort> orientationValue) ?? false) |
There was a problem hiding this comment.
This seems out of place to be in this PR
There was a problem hiding this comment.
I had some camera photos with EXIF orientation data show up as 16:9 instead of 9:16. It is really an edge case and I can remove this if it is out of scope.
There was a problem hiding this comment.
That'd be a separate issue post to make, a separate PR, likely not focused into the Image Batch tool code
| (int scaledInputWidth, int scaledInputHeight) = Utilities.ResToModelFit(imgData.Width, imgData.Height, inputSideLength * inputSideLength, 16); | ||
| image = (Image)((ImageFile)image).Resize(scaledInputWidth, scaledInputHeight); | ||
| imgData = image.ToIS; | ||
| if (useSameSideLength) |
There was a problem hiding this comment.
this boolean and code around it make no sense
There was a problem hiding this comment.
This was made with batch 'image prompts' in mind, which would follow a different flow than the batch 'input image'.
- Allow users to resize the input images while maintaining aspect ratio
- Allow users to set the output images resolution while maintaining aspect ratio
Initially I had only used option 1, which resized the input image and set the output to exact same resolution. When I looked at the actual request the user had made, they had asked for the option to set the output size as well.
I think it would be possible to batch as 'image prompts' and include a <refiner> in the prompt set to upscale and achieve more or less the same effect. That is a little more costly with time. The more I think about it I'm inclined to this this is a bit of an edge case and maybe we should just keep option 1.
There was a problem hiding this comment.
per conversation I have removed 'output' scaling functionality as well as renamed 'input side length' to just 'side length'
| + makeSliderInput(null, 'ext_image_batcher_input_side_length', '', 'Input Side Length', '', 1024, 64, 4096, 64, 4096, 64, false, false, false) | ||
| + `</div>` | ||
| + `<span id="ext_image_batcher_output_side_length_wrap" style="display:none;width:100%;max-width:512px;">` | ||
| + makeSliderInput(null, 'ext_image_batcher_output_side_length', '', 'Output Side Length', '', 1024, 64, 4096, 64, 4096, 64, false, false, false) |
There was a problem hiding this comment.
This value makes no sense to have
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
|
|
||
| The list of experienced maintainers currently approved for this experiment are: | ||
| - Alex Goodwin (mcmonkey) | ||
| - Glen Carpenter |
There was a problem hiding this comment.
This restriction was not a joke.
|
Closed and blacklisted for intentional violation of contributor requirements. |
Add "Scale Input To Side Length" Resolution Mode to Image Batch Tool
This was requested in Discord.
Adds a new resolution option to the Image Batch Tool that scales based on a target side-length pixel budget while preserving aspect ratio, with separate controls for input and output when needed.
What's New
Changes