taggui icon indicating copy to clipboard operation
taggui copied to clipboard

Feature request: simple image modification (crop, resize, mask painting)

Open ChristianMayer opened this issue 1 year ago • 1 comments

General request

It would be great to be able to draw a selection frame in TagGUI which would then crop the image to the selected content and resize it (only shrinking) to then fit a configured maximum size. And for masked training it would be great when the mask could be drawn in TagGUI as well.

Refinement

It would be great to be able to configure a list of valid aspect ratios or sizes and then the selection frame will automatically be constraint to them. This would be great for batched training and keeping the number of batches small.

Implementation idea

TagGUI doesn't modify the images only the captions. This is great as it prevents you from worrying about modifying precious data! So I suggest to store the image manipulation data either in a hidden tag or in a side file like my_image_name.jpg.meta. And then TagGUI could offers an export menu entry where then all images are cropped and resized and stored together with their caption file in a new directory.

Additional information

  • Resizing an image should use the best algorithm. Lanczos comes to mind and there should be implementations of it easily available in libraries. After shrinking an image usually you should follow with a slight sharpening (e.g. unsharp mask with 0.5 pixel width).
  • Image mask can come in two kinds, either it's stored in the image itself (when it is stored in png format) or it comes in an additional greyscale image.

ChristianMayer avatar Oct 28 '24 17:10 ChristianMayer

PR #353 does the cropping part. And it allows masks by placing rectangle marks on the image, but it doesn't allow real mask painting. The masks are then exported in the image itself as transparency. Did you have a look at this PR?

StableLlama avatar Apr 12 '25 15:04 StableLlama