-
-
Notifications
You must be signed in to change notification settings - Fork 18
Prevent overcropping images when publishing (BL-15772) #7640
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
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| src/BloomExe/ImageProcessing/ImageUtils.cs | Added srcUsageCount dictionary to prevent overcropping when same image file is used multiple times with different crops |
Sequence Diagram
sequenceDiagram
participant Caller
participant ReallyCropImages
participant Dict as Dictionaries
participant ReallyCropImage
participant MakeCroppedImage
Caller->>ReallyCropImages: bookDom, imageSourceFolder, imageDestFolder
Note over ReallyCropImages,Dict: First pass: Analyze all images
ReallyCropImages->>Dict: Initialize uncroppedSrcNames (HashSet)
ReallyCropImages->>Dict: Initialize cropped (Dictionary)
ReallyCropImages->>Dict: Initialize srcUsageCount (Dictionary)
loop For each img element
ReallyCropImages->>ReallyCropImages: Get src attribute
alt Image is not cropped
ReallyCropImages->>Dict: Add src to uncroppedSrcNames
end
ReallyCropImages->>Dict: Increment srcUsageCount[src]
end
Note over ReallyCropImages,MakeCroppedImage: Second pass: Process cropping
loop For each img element with cropping
ReallyCropImages->>ReallyCropImages: Get src, style, canvas dimensions
ReallyCropImages->>ReallyCropImages: Create key from src|style|dimensions
alt Key exists in cropped dict
ReallyCropImages->>ReallyCropImages: Reuse existing cropped filename
else Key not in cropped dict
ReallyCropImages->>ReallyCropImages: Calculate needNewName
Note right of ReallyCropImages: needNewName = uncroppedSrcNames.Contains(src)<br/>|| srcUsageCount[src] > 1
ReallyCropImages->>ReallyCropImage: Process image with needNewName flag
ReallyCropImage->>MakeCroppedImage: Create cropped version
MakeCroppedImage-->>ReallyCropImage: croppedImagePath
alt needNewName is true
ReallyCropImage->>ReallyCropImage: Use new GUID-based filename
else needNewName is false
ReallyCropImage->>ReallyCropImage: Overwrite original file
end
ReallyCropImage-->>ReallyCropImages: croppedFileName
ReallyCropImages->>Dict: Store croppedFileName in cropped[key]
end
end
ReallyCropImages-->>Caller: Processing complete
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.
1 file reviewed, no comments
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.
4010ad3 to
09136b9
Compare
09136b9 to
a0c19bd
Compare
This change is