Skip to content

Commit 8d057bf

Browse files
authored
Merge pull request #98 from Pascal-Institute/develop
Version Up
2 parents a85a3f4 + 1aeed71 commit 8d057bf

34 files changed

+2217
-1295
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
[![DeepWiki](https://img.shields.io/badge/DeepWiki-Pascal--Institute%2Fpegasus-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/Pascal-Institute/pegasus)
2+
23
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
34

45
# pegasus
56

67
#### The Image Processing Tool based on Electron framework & sharp npm package
78

8-
<img width="3071" height="1806" alt="image" src="https://github.com/user-attachments/assets/853e02b8-dffb-44e4-a5f8-d74b81265c3e" />
9-
9+
## 0. Application mission : Give wings to pixels
1010

1111
## 1. Requirements
1212

1313
### For Development
14+
1415
- IDE : Visual Studio Code (Recommemded)
1516
- node.js : v22.18.0 (At least version)
1617

@@ -21,11 +22,13 @@ npm install -g electron
2122
```bash
2223
npm install --save electron electron-reload electron-rebuild electron-builder sharp sharp-ico sharp-bmp fs imgkit
2324
```
25+
2426
### For Application use
2527

2628
1. Install node.js : https://nodejs.org/
2729

2830
2. Install electron
31+
2932
```bash
3033
npm install -g electron
3134
```
@@ -43,6 +46,7 @@ npm update
4346
## 3-1. How to execute
4447

4548
### window
49+
4650
```bash
4751
electron .
4852
```
@@ -54,6 +58,7 @@ npm start
5458
```
5559

5660
### linux line-up
61+
5762
```bash
5863
electron . --ozone-platform=x11
5964
```
@@ -69,9 +74,11 @@ npm run build
6974
### 4-1. Availiable file extension
7075

7176
```bash
72-
png jpg jpeg webp gif bmp ico tiff tif
77+
png svg jpg jpeg webp gif bmp ico tiff tif
7378
```
7479

80+
**Note:** Animated GIF files are now supported! When you load an animated GIF, playback controls appear automatically. See [GIF Animation Documentation](docs/GIF_ANIMATION.md) for details.
81+
7582
#### 4-2. extension converting
7683

7784
### 4-3. Image Processing

assets/dilate.ico

2.31 KB
Binary file not shown.

assets/erode.ico

1.41 KB
Binary file not shown.

assets/pad.ico

1.28 KB
Binary file not shown.

css/filter_panel.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#medianBtn:hover,
44
#bitwiseBtn:hover,
55
#negativeBtn:hover,
6-
#normalizeBtn:hover {
6+
#normalizeBtn:hover,
7+
#dilateBtn:hover,
8+
#erodeBtn:hover {
9+
background-color: #e0e0e0;
710
cursor: pointer;
811
}

css/paint_panel.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#grayScaleBtn:hover,
33
#tintExecuteBtn:hover,
44
#watermarkBtn:hover,
5-
#colorpickerBtn:hover {
5+
#colorpickerBtn:hover,
6+
#colorpickerBox:hover,
7+
#padBtn:hover {
68
cursor: pointer;
79
}
810

@@ -71,4 +73,4 @@
7173
align-items: center;
7274
flex-direction: column;
7375
margin-left: 5px;
74-
}
76+
}

css/styles.css

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ select#extensionComboBox {
9090
transform: translateY(1px);
9191
}
9292

93-
#nameSpan {
93+
#nameInput {
9494
position: absolute;
9595
top: 8px;
9696
left: 8px;
@@ -152,16 +152,3 @@ select#extensionComboBox {
152152
#error_msg {
153153
background-color: #f29999;
154154
}
155-
156-
#scroll-container {
157-
position: relative;
158-
width: auto !important;
159-
overflow-x: auto;
160-
overflow-y: hidden;
161-
white-space: nowrap;
162-
display: flex;
163-
align-items: center;
164-
box-sizing: border-box;
165-
padding: 48px 48px 48px 48px;
166-
scroll-behavior: smooth;
167-
}

docs/GIF_ANIMATION.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# GIF Animation Support
2+
3+
## Overview
4+
5+
Pegasus now supports displaying and playing animated GIF files. When you load an animated GIF, the application automatically detects the animation and displays playback controls.
6+
7+
## Features
8+
9+
### Automatic Detection
10+
- When a GIF file is loaded, the application automatically detects if it contains multiple frames (animated)
11+
- Static GIFs (single frame) are displayed normally without playback controls
12+
- Animated GIFs show playback controls below the image
13+
14+
### Playback Controls
15+
16+
The GIF playback controls appear automatically for animated GIFs and include:
17+
18+
1. **Play/Pause Button (▶/⏸)**
19+
- Click to play or pause the animation
20+
- Animation plays automatically when first loaded
21+
- Shows ▶ when paused, ⏸ when playing
22+
23+
2. **Stop Button (■)**
24+
- Stops playback and returns to the first frame
25+
- Useful for resetting the animation
26+
27+
3. **Frame Counter**
28+
- Displays current frame / total frames (e.g., "1/316")
29+
- Updates in real-time as animation plays
30+
31+
### Animation Behavior
32+
33+
- **Auto-play**: Animated GIFs start playing automatically when loaded
34+
- **Frame timing**: Each frame respects its original delay timing from the GIF metadata
35+
- **Looping**: Supports infinite looping (most GIFs) and limited loops
36+
- **Pause on operations**: Animation automatically pauses when you perform operations like:
37+
- Undo/Redo (Ctrl+Z / Ctrl+Y)
38+
- Crop, resize, filter, rotate
39+
- Format conversion
40+
41+
### Technical Details
42+
43+
- Uses Sharp library's native GIF animation support
44+
- Extracts individual frames on-demand for smooth playback
45+
- Respects original frame delays (in milliseconds)
46+
- Memory efficient - doesn't pre-load all frames
47+
48+
## Usage
49+
50+
### Opening Animated GIFs
51+
52+
1. **Via File Menu**:
53+
- Click File → Open
54+
- Select a GIF file
55+
- If animated, controls appear automatically
56+
57+
2. **Via Drag & Drop**:
58+
- Drag a GIF file into the application
59+
- Drop it on the canvas area
60+
- Controls appear if the GIF is animated
61+
62+
3. **Via Paste**:
63+
- Copy a GIF file to clipboard
64+
- Press Ctrl+V in the application
65+
- Controls appear if the GIF is animated
66+
67+
### Controlling Playback
68+
69+
- **Play**: Click the ▶ button or it plays automatically
70+
- **Pause**: Click the ⏸ button to pause
71+
- **Stop**: Click the ■ button to stop and reset to first frame
72+
- **Frame info**: Watch the frame counter to see current position
73+
74+
### Working with Animated GIFs
75+
76+
1. **Editing**: You can apply filters, resize, crop, etc. to the current displayed frame
77+
2. **Converting**: When you convert to another format, animation is removed (uses current frame)
78+
3. **Saving**: Saves the original animated GIF if extension stays as .gif
79+
4. **Format Change**: Changing extension to non-GIF formats will save the current frame only
80+
81+
## Examples
82+
83+
### Loading an Animated GIF
84+
```javascript
85+
// The application automatically detects animation
86+
// You just open the file normally
87+
await layer.openImage('path/to/animated.gif');
88+
// Controls appear automatically if animated
89+
```
90+
91+
### Checking if GIF is Animated
92+
```javascript
93+
if (layer.isAnimatedGif()) {
94+
console.log('This is an animated GIF with', layer.gifMetadata.pages, 'frames');
95+
}
96+
```
97+
98+
### Manual Playback Control
99+
```javascript
100+
// Play
101+
layer.playGifAnimation();
102+
103+
// Pause
104+
layer.pauseGifAnimation();
105+
106+
// Stop (reset to frame 0)
107+
layer.stopGifPlayback();
108+
```
109+
110+
## Supported GIF Features
111+
112+
**Supported**:
113+
- Multiple frames (animated GIFs)
114+
- Per-frame delay timing
115+
- Infinite looping (loop = 0)
116+
- Limited looping (loop = N)
117+
- Variable frame delays
118+
- Transparent backgrounds
119+
- Palette-based GIFs
120+
121+
**Not Supported**:
122+
- Editing individual frames
123+
- Creating new animated GIFs from scratch
124+
- Adding/removing frames
125+
- Modifying frame delays
126+
127+
## Performance Notes
128+
129+
- Frame extraction is on-demand (not pre-loaded)
130+
- Smooth playback for most GIFs
131+
- Large GIFs (many frames or high resolution) may have slight delays during frame extraction
132+
- Memory usage is efficient as frames are not kept in memory
133+
134+
## Troubleshooting
135+
136+
### GIF doesn't animate
137+
- Check if it's a static GIF (only 1 frame)
138+
- Verify the file is not corrupted
139+
- Try re-opening the file
140+
141+
### Playback is choppy
142+
- This is normal for GIFs with very short frame delays (<50ms)
143+
- Try a different GIF to verify
144+
- Check system resources (CPU usage)
145+
146+
### Controls don't appear
147+
- Ensure the GIF has multiple frames
148+
- Check the extension is `.gif`
149+
- Try reloading the file
150+
151+
## Implementation Details
152+
153+
The GIF animation support is implemented in:
154+
155+
1. **ImageLoader** (`imgkit/processing/image_loader.js`)
156+
- Detects animated GIFs via metadata (pages > 1)
157+
- Extracts individual frames using Sharp's page option
158+
- Returns GIF metadata (pages, delay, loop)
159+
160+
2. **ImageLayer** (`imgkit/core/image_layer.js`)
161+
- Manages animation state and playback
162+
- Creates and controls UI elements (buttons, counter)
163+
- Schedules frame display based on delays
164+
- Handles pause/play/stop logic
165+
166+
3. **Sharp Library**
167+
- Provides native GIF reading with animation support
168+
- Extracts frames via `sharp(buffer, { page: N })`
169+
- Returns metadata with pages, delay, loop info

0 commit comments

Comments
 (0)