-
Notifications
You must be signed in to change notification settings - Fork 1
Test #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test #27
Changes from all commits
32f0e5c
1c7eff4
c7f221e
93994d6
09a359d
ffa3568
64f4432
3351dd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,11 @@ | |
| from io import BytesIO | ||
|
|
||
| from faststack.models import DecodedImage | ||
| from PySide6.QtGui import QImage | ||
| try: | ||
| from PySide6.QtGui import QImage | ||
| except Exception: | ||
| QImage = None | ||
|
|
||
| import threading | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
@@ -191,6 +195,12 @@ def clear(self): | |
| # Optionally also reset edits if that matches your mental model: | ||
| # self.current_edits = self._initial_edits() | ||
|
|
||
| def reset_edits(self): | ||
| """Reset edits to initial values and bump revision.""" | ||
| with self._lock: | ||
| self.current_edits = self._initial_edits() | ||
| self._edits_rev += 1 | ||
|
|
||
| def _initial_edits(self) -> Dict[str, Any]: | ||
| return { | ||
| 'brightness': 0.0, | ||
|
|
@@ -265,7 +275,7 @@ def load_image(self, filepath: str, cached_preview: Optional[DecodedImage] = Non | |
| return False | ||
|
|
||
|
|
||
| def _apply_edits(self, img: Image.Image, edits: Optional[Dict[str, Any]] = None, *, for_export: bool = False) -> Image.Image: | ||
| def _apply_edits(self, img: Image.Image, edits: Optional[Dict[str, Any]] = None, *, for_export: bool = True) -> Image.Image: | ||
| """Applies all current edits to the provided PIL Image.""" | ||
|
|
||
| if edits is None: | ||
|
|
@@ -343,7 +353,7 @@ def _apply_edits(self, img: Image.Image, edits: Optional[Dict[str, Any]] = None, | |
| if abs(blacks) > 0.001 or abs(whites) > 0.001: | ||
| arr = np.array(img, dtype=np.float32) | ||
| black_point = -blacks * 40 | ||
| white_point = 255 - whites * 40 | ||
| white_point = 255 + whites * 40 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's look at the actual code around line 356
sed -n '350,360p' faststack/imaging/editor.pyRepository: AlanRockefeller/faststack Length of output: 545 🏁 Script executed: # Now check the comment and auto_levels calculation around lines 510-530
sed -n '510,530p' faststack/imaging/editor.pyRepository: AlanRockefeller/faststack Length of output: 847 🏁 Script executed: # Check for whites property usage in provider.py
rg -nP '\bwhites\b' faststack/ui/provider.py -C 3Repository: AlanRockefeller/faststack Length of output: 711 Update the outdated comment to reflect the current formula. The Required comment update # Calculate parameters to map p_low->0 and p_high->255
# Logic matches _apply_edits:
# black_point = -blacks * 40
-# white_point = 255 - whites * 40
+# white_point = 255 + whites * 40
🤖 Prompt for AI Agents |
||
| # Prevent division by zero | ||
| if abs(white_point - black_point) < 0.001: | ||
| white_point = black_point + 0.001 | ||
|
|
@@ -510,8 +520,8 @@ def auto_levels(self, threshold_percent: float = 0.1) -> Tuple[float, float]: | |
| blacks = -float(p_low) / 40.0 | ||
|
|
||
| # We want white_point to be p_high | ||
| # p_high = 255 - whites * 40 => whites = (255.0 - float(p_high)) / 40.0 | ||
| whites = (255.0 - float(p_high)) / 40.0 | ||
| # p_high = 255 + whites * 40 => whites = (float(p_high) - 255) / 40.0 | ||
| whites = (float(p_high) - 255.0) / 40.0 | ||
|
|
||
| # Update state | ||
| with self._lock: | ||
|
|
@@ -545,6 +555,10 @@ def get_preview_data_cached(self, allow_compute: bool = True) -> Optional[Decode | |
|
|
||
| # Heavy computation outside lock using snapshot | ||
| img = self._apply_edits(base, edits=edits, for_export=False) | ||
|
|
||
| if QImage is None: | ||
| raise ImportError("PySide6.QtGui.QImage is required for get_preview_data_cached") | ||
|
|
||
| # The image is in RGB mode after _apply_edits | ||
| buffer = img.tobytes() | ||
| decoded = DecodedImage( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AlanRockefeller/faststack
Length of output: 2322
🏁 Script executed:
Repository: AlanRockefeller/faststack
Length of output: 197
🏁 Script executed:
Repository: AlanRockefeller/faststack
Length of output: 51
🏁 Script executed:
Repository: AlanRockefeller/faststack
Length of output: 395
🏁 Script executed:
Repository: AlanRockefeller/faststack
Length of output: 623
Address breaking change from
for_export=Falsetofor_export=Truedefault.External code depends on the default value:
verify_wb.py(lines 25, 48) andtest_new_features.py(lines 52, 79) call_apply_edits()without explicitly passingfor_export. Changing the default fromFalsetoTruebreaks these callers' behavior without code modification. Either revert the default or update all dependent call sites.🤖 Prompt for AI Agents