image-speech-bubble-transformer
Version:
TypeScript library for applying speech bubble effects to images
63 lines (44 loc) • 1.43 kB
Markdown
A TypeScript library for applying speech bubble effects to images with various transformation options.
```bash
npm install image-speech-bubble-transformer
```
```typescript
import {
createSpeechBubbleTransformer,
Orientation,
} from "image-speech-bubble-transformer";
import fs from "fs/promises";
async function example() {
// Create transformer instance
const transformer = createSpeechBubbleTransformer();
// Read image buffer
const inputBuffer = await fs.readFile("input.png");
// Process image with options
const processedBuffer = await transformer.processSpeechBubble(inputBuffer, {
mirror: true,
orientation: Orientation.LEFT,
});
// Save processed image
await transformer.processAndSave(inputBuffer, "output.png", {
mirror: true,
orientation: Orientation.LEFT,
});
}
```
- Creates a transformer instance
- `assetsDir`: Optional path to custom assets directory
- Applies speech bubble effect to image
- Options:
- `mirror`: Flip horizontally
- `orientation`: Rotate speech bubble
- `speechBubblePath`: Custom speech bubble image
- Processes and saves image in one step
- .png, .jpg, .jpeg, .gif, .bmp, .webp, .tiff