Skip to content

Commit

Permalink
Don't crop result images when applying them #1598 #1608
Browse files Browse the repository at this point in the history
- only position them by the job bounds offset
  • Loading branch information
Acly committed Feb 15, 2025
1 parent c19f62e commit 9bb94ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion ai_diffusion/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import krita
from krita import Krita
from PyQt5.QtCore import QObject, QUuid, QByteArray, QTimer, pyqtSignal
from PyQt5.QtGui import QImage

from .image import Extent, Bounds, Mask, Image
from .layer import Layer, LayerManager, LayerType
Expand Down
7 changes: 3 additions & 4 deletions ai_diffusion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,13 @@ def hide_preview(self):
self._layer.hide()

def apply_result(self, image: Image, params: JobParams, behavior: ApplyBehavior, prefix=""):
if image.extent != params.bounds.extent:
image = Image.crop(image, Bounds(0, 0, *params.bounds.extent))
bounds = Bounds(*params.bounds.offset, *image.extent)
if len(params.regions) == 0:
if behavior is ApplyBehavior.replace:
self.layers.update_layer_image(self.layers.active, image, params.bounds)
self.layers.update_layer_image(self.layers.active, image, bounds)
else:
name = f"{prefix}{trim_text(params.name, 200)} ({params.seed})"
self.layers.create(name, image, params.bounds)
self.layers.create(name, image, bounds)
else: # apply to regions
with RestoreActiveLayer(self.layers) as restore:
active_id = Region.link_target(self.layers.active).id_string
Expand Down

0 comments on commit 9bb94ac

Please sign in to comment.