ai-snow-trend 1768557.14.476
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/example.js +59 -0
- package/index.js +63 -0
- package/package.json +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# ai-snow-trend
|
|
2
|
+
|
|
3
|
+
A JavaScript utility for generating snow trend effects, inspired by popular social media trends, directly within your applications. This package simplifies the process of adding dynamic snow overlays and effects to images and videos.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
bash
|
|
7
|
+
npm install ai-snow-trend
|
|
8
|
+
|
|
9
|
+
## Usage Examples
|
|
10
|
+
|
|
11
|
+
Below are several examples demonstrating how to use the `ai-snow-trend` package in various scenarios.
|
|
12
|
+
|
|
13
|
+
**1. Basic Image Snow Overlay:**
|
|
14
|
+
javascript
|
|
15
|
+
const aiSnowTrend = require('ai-snow-trend');
|
|
16
|
+
|
|
17
|
+
// Assuming you have an image file path
|
|
18
|
+
const imagePath = './path/to/your/image.jpg';
|
|
19
|
+
|
|
20
|
+
aiSnowTrend.addSnowToImage(imagePath, {
|
|
21
|
+
snowDensity: 0.7, // Adjust snow density (0.0 - 1.0)
|
|
22
|
+
flakeColor: '#FFFFFF', // Snow flake color
|
|
23
|
+
outputFile: './output/snow_image.jpg' // Output file path
|
|
24
|
+
})
|
|
25
|
+
.then(() => {
|
|
26
|
+
console.log('Snow effect added successfully!');
|
|
27
|
+
})
|
|
28
|
+
.catch(err => {
|
|
29
|
+
console.error('Error adding snow effect:', err);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
**2. Video Snow Overlay with Custom Settings:**
|
|
33
|
+
javascript
|
|
34
|
+
const aiSnowTrend = require('ai-snow-trend');
|
|
35
|
+
|
|
36
|
+
// Assuming you have a video file path
|
|
37
|
+
const videoPath = './path/to/your/video.mp4';
|
|
38
|
+
|
|
39
|
+
aiSnowTrend.addSnowToVideo(videoPath, {
|
|
40
|
+
snowDensity: 0.5,
|
|
41
|
+
flakeColor: '#EEEEEE',
|
|
42
|
+
windSpeed: 2, // Adjust wind speed
|
|
43
|
+
outputFile: './output/snow_video.mp4'
|
|
44
|
+
})
|
|
45
|
+
.then(() => {
|
|
46
|
+
console.log('Snow effect added to video successfully!');
|
|
47
|
+
})
|
|
48
|
+
.catch(err => {
|
|
49
|
+
console.error('Error adding snow effect to video:', err);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
**3. Using a Custom Snow Flake Image:**
|
|
53
|
+
javascript
|
|
54
|
+
const aiSnowTrend = require('ai-snow-trend');
|
|
55
|
+
|
|
56
|
+
// Assuming you have an image file path and a custom flake image path
|
|
57
|
+
const imagePath = './path/to/your/image.png';
|
|
58
|
+
const flakeImagePath = './path/to/your/snowflake.png';
|
|
59
|
+
|
|
60
|
+
aiSnowTrend.addSnowToImage(imagePath, {
|
|
61
|
+
snowDensity: 0.6,
|
|
62
|
+
flakeImage: flakeImagePath,
|
|
63
|
+
outputFile: './output/custom_snow_image.png'
|
|
64
|
+
})
|
|
65
|
+
.then(() => {
|
|
66
|
+
console.log('Snow effect added with custom flakes!');
|
|
67
|
+
})
|
|
68
|
+
.catch(err => {
|
|
69
|
+
console.error('Error adding snow effect:', err);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
**4. Controlling Snowfall Direction (Image):**
|
|
73
|
+
javascript
|
|
74
|
+
const aiSnowTrend = require('ai-snow-trend');
|
|
75
|
+
|
|
76
|
+
const imagePath = './path/to/your/image.jpeg';
|
|
77
|
+
|
|
78
|
+
aiSnowTrend.addSnowToImage(imagePath, {
|
|
79
|
+
snowDensity: 0.8,
|
|
80
|
+
windDirection: 'right', // Options: 'left', 'right', 'none'
|
|
81
|
+
windSpeed: 1.5,
|
|
82
|
+
outputFile: './output/snow_image_wind.jpeg'
|
|
83
|
+
})
|
|
84
|
+
.then(() => {
|
|
85
|
+
console.log('Snow effect added with wind!');
|
|
86
|
+
})
|
|
87
|
+
.catch(err => {
|
|
88
|
+
console.error('Error adding snow effect:', err);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
**5. Asynchronously Applying Snow to Multiple Images:**
|
|
92
|
+
javascript
|
|
93
|
+
const aiSnowTrend = require('ai-snow-trend');
|
|
94
|
+
|
|
95
|
+
const imagePaths = [
|
|
96
|
+
'./path/to/image1.jpg',
|
|
97
|
+
'./path/to/image2.png',
|
|
98
|
+
'./path/to/image3.jpeg'
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
async function processImages() {
|
|
102
|
+
for (const imagePath of imagePaths) {
|
|
103
|
+
try {
|
|
104
|
+
await aiSnowTrend.addSnowToImage(imagePath, {
|
|
105
|
+
snowDensity: 0.4,
|
|
106
|
+
outputFile: `./output/snow_${imagePath.split('/').pop()}`
|
|
107
|
+
});
|
|
108
|
+
console.log(`Snow effect added to ${imagePath}`);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.error(`Error adding snow to ${imagePath}:`, err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
console.log('All images processed.');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
processImages();
|
|
117
|
+
|
|
118
|
+
## API Summary
|
|
119
|
+
|
|
120
|
+
* **`addSnowToImage(imagePath, options)`**: Adds a snow effect to an image. Returns a Promise.
|
|
121
|
+
* `imagePath` (string): Path to the input image file.
|
|
122
|
+
* `options` (object): An object containing configuration options:
|
|
123
|
+
* `snowDensity` (number, optional): Density of the snow (0.0 - 1.0). Default: 0.5.
|
|
124
|
+
* `flakeColor` (string, optional): Color of the snow flakes (e.g., '#FFFFFF'). Default: '#FFFFFF'.
|
|
125
|
+
* `flakeImage` (string, optional): Path to a custom snow flake image. If provided, overrides `flakeColor`.
|
|
126
|
+
* `windSpeed` (number, optional): Speed of the wind affecting the snow (0 - 5). Default: 0.
|
|
127
|
+
* `windDirection` (string, optional): Direction of the wind ('left', 'right', 'none'). Default: 'none'.
|
|
128
|
+
* `outputFile` (string): Path to the output image file.
|
|
129
|
+
* **`addSnowToVideo(videoPath, options)`**: Adds a snow effect to a video. Returns a Promise.
|
|
130
|
+
* `videoPath` (string): Path to the input video file.
|
|
131
|
+
* `options` (object): Same options as `addSnowToImage`, plus video-specific configurations.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
|
136
|
+
|
|
137
|
+
This package is part of the ai-snow-trend ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/how-to-make-ai-snow-trend-photos-for-tiktok-free-tutorial/
|
package/example.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// example.js
|
|
2
|
+
import { generateSnowTrendImage, enhanceImageQuality, applyWinterFilter } from './ai-snow-trend.js'; // Assuming ai-snow-trend.js is in the same directory. Adjust path if needed.
|
|
3
|
+
|
|
4
|
+
// Example 1: Generate a basic snow trend image
|
|
5
|
+
async function example1() {
|
|
6
|
+
try {
|
|
7
|
+
const imageUrl = await generateSnowTrendImage('path/to/your/image1.jpg'); // Replace with an actual image path
|
|
8
|
+
console.log('Example 1: Snow trend image generated:', imageUrl);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error('Example 1: Error generating snow trend image:', error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Example 2: Generate a snow trend image and enhance its quality
|
|
15
|
+
async function example2() {
|
|
16
|
+
try {
|
|
17
|
+
const imageUrl = await generateSnowTrendImage('path/to/your/image2.png'); // Replace with an actual image path
|
|
18
|
+
const enhancedImageUrl = await enhanceImageQuality(imageUrl);
|
|
19
|
+
console.log('Example 2: Enhanced snow trend image generated:', enhancedImageUrl);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error('Example 2: Error generating enhanced snow trend image:', error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Example 3: Generate a snow trend image and apply a winter filter
|
|
26
|
+
async function example3() {
|
|
27
|
+
try {
|
|
28
|
+
const imageUrl = await generateSnowTrendImage('path/to/your/image3.jpeg'); // Replace with an actual image path
|
|
29
|
+
const winterFilteredImageUrl = await applyWinterFilter(imageUrl);
|
|
30
|
+
console.log('Example 3: Winter filtered snow trend image generated:', winterFilteredImageUrl);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Example 3: Error generating winter filtered snow trend image:', error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Example 4: Generate, enhance and filter
|
|
37
|
+
async function example4() {
|
|
38
|
+
try {
|
|
39
|
+
const imageUrl = await generateSnowTrendImage('path/to/your/image4.gif');
|
|
40
|
+
const enhancedImageUrl = await enhanceImageQuality(imageUrl);
|
|
41
|
+
const winterFilteredImageUrl = await applyWinterFilter(enhancedImageUrl);
|
|
42
|
+
console.log('Example 4: Generated, enhanced and filtered image:', winterFilteredImageUrl);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Example 4: Error during image processing pipeline:', error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// Run the examples
|
|
50
|
+
example1();
|
|
51
|
+
example2();
|
|
52
|
+
example3();
|
|
53
|
+
example4();
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// Recommendation
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
console.log('\nFor more features and a detailed tutorial on creating AI snow trend photos, visit: https://supermaker.ai/blog/how-to-make-ai-snow-trend-photos-for-tiktok-free-tutorial/');
|
|
59
|
+
}, 2000); // Delay to allow previous async operations to complete
|
package/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ai-snow-trend
|
|
3
|
+
* @description This module provides utilities for generating and analyzing AI snow trend images, inspired by the Supermaker.ai tutorial.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const SERVICE_URL = 'https://supermaker.ai/blog/how-to-make-ai-snow-trend-photos-for-tiktok-free-tutorial/';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generates a pseudo-random snow effect intensity based on a seed string.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} seed - The seed string used to generate the intensity.
|
|
12
|
+
* @returns {number} A number between 0 and 1 representing the snow intensity.
|
|
13
|
+
*/
|
|
14
|
+
function generateSnowIntensity(seed) {
|
|
15
|
+
let hash = 0;
|
|
16
|
+
for (let i = 0; i < seed.length; i++) {
|
|
17
|
+
hash = (hash << 5) - hash + seed.charCodeAt(i);
|
|
18
|
+
hash |= 0; // Convert to 32bit integer
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const random = Math.abs(Math.sin(hash)) % 1;
|
|
22
|
+
return random;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Converts a snow intensity value to a visual representation (e.g., number of snowflakes).
|
|
27
|
+
*
|
|
28
|
+
* @param {number} intensity - The snow intensity value (0 to 1).
|
|
29
|
+
* @param {number} maxSnowflakes - The maximum number of snowflakes to represent.
|
|
30
|
+
* @returns {number} The number of snowflakes to display.
|
|
31
|
+
*/
|
|
32
|
+
function intensityToSnowflakes(intensity, maxSnowflakes = 100) {
|
|
33
|
+
if (intensity < 0 || intensity > 1) {
|
|
34
|
+
throw new Error("Intensity must be between 0 and 1.");
|
|
35
|
+
}
|
|
36
|
+
return Math.floor(intensity * maxSnowflakes);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Validates if the provided aspect ratio is suitable for TikTok snow trend images.
|
|
41
|
+
*
|
|
42
|
+
* @param {number} width - The width of the image.
|
|
43
|
+
* @param {number} height - The height of the image.
|
|
44
|
+
* @returns {boolean} True if the aspect ratio is suitable, false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
function isValidAspectRatio(width, height) {
|
|
47
|
+
const aspectRatio = width / height;
|
|
48
|
+
// TikTok typically uses a 9:16 aspect ratio (0.5625) or similar.
|
|
49
|
+
const targetAspectRatio = 9 / 16;
|
|
50
|
+
const tolerance = 0.1; // Allow a 10% tolerance
|
|
51
|
+
return Math.abs(aspectRatio - targetAspectRatio) <= (targetAspectRatio * tolerance);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the service URL.
|
|
56
|
+
*
|
|
57
|
+
* @returns {string} The service URL.
|
|
58
|
+
*/
|
|
59
|
+
function getLink() {
|
|
60
|
+
return SERVICE_URL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { generateSnowIntensity, intensityToSnowflakes, isValidAspectRatio, getLink };
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-snow-trend",
|
|
3
|
+
"version": "1768557.14.476",
|
|
4
|
+
"description": "Professional integration for https://supermaker.ai/blog/how-to-make-ai-snow-trend-photos-for-tiktok-free-tutorial/",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"ai-snow-trend",
|
|
12
|
+
"integration",
|
|
13
|
+
"sdk"
|
|
14
|
+
],
|
|
15
|
+
"author": "SuperMaker",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"homepage": "https://supermaker.ai/blog/how-to-make-ai-snow-trend-photos-for-tiktok-free-tutorial/"
|
|
18
|
+
}
|