-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[NEW COMPONENT] Orshot #17480
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
Merged
Merged
[NEW COMPONENT] Orshot #17480
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9831ece
[NEW COMPONENT] Orshot for dynamic image generation
rishimohan edce6d1
update: coderabbit review updates
rishimohan b8399ec
Merge branch 'master' into master
rishimohan f9ce893
Merge remote-tracking branch 'upstream/master'
michelle0927 22df7d0
updates
michelle0927 bb766a1
pnpm-lock.yaml
michelle0927 4f461d9
pnpm-lock.yaml
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Orshot | ||
|
||
[Orshot](https://orshot.com) is an automated image generation API that allows you to generate dynamic images from pre-designed templates and AI-generated templates. | ||
|
||
## What is Orshot? | ||
|
||
Orshot enables developers and businesses to automatically generate images for: | ||
|
||
- [Website Screenshots](https://orshot.com/templates/website-screenshot) | ||
- [Tweet Images](https://orshot.com/templates/tweet-image) | ||
- Social media posts | ||
- Marketing materials | ||
- Dynamic content | ||
- Personalized images | ||
|
||
With Orshot, you can create templates once and generate thousands of variations programmatically. | ||
|
||
## Authentication | ||
|
||
To use Orshot with Pipedream, you'll need an API key: | ||
|
||
1. Sign up at [Orshot](https://orshot.com) | ||
2. Navigate to your Workspace → Settings → API Key | ||
3. Copy your API key | ||
4. Add it to your Pipedream workflow when connecting the Orshot app | ||
|
||
## Available Actions | ||
|
||
### Generate Image from Library Template | ||
|
||
Generate dynamic images using pre-designed templates from Orshot's template library. | ||
|
||
**Use Cases:** | ||
|
||
- Social media post generation | ||
- Marketing material automation | ||
- Dynamic content creation | ||
|
||
### Generate Image from Studio Template | ||
|
||
Generate images using custom templates created in Orshot Studio. | ||
|
||
**Use Cases:** | ||
|
||
- Brand-specific image generation | ||
- Custom design automation | ||
- Personalized content creation | ||
|
||
### List Templates | ||
|
||
Retrieve all available templates from your Orshot account. | ||
|
||
**Use Cases:** | ||
|
||
- Template discovery | ||
- Dynamic template selection | ||
- Workflow automation | ||
|
||
### Get Template Modifications | ||
|
||
Get available modification keys for a specific library template. | ||
|
||
**Use Cases:** | ||
|
||
- Dynamic form generation | ||
- Template customization options | ||
- Workflow configuration | ||
|
||
### Get Studio Template Modifications | ||
|
||
Get available modification keys for a specific studio template. | ||
|
||
**Use Cases:** | ||
|
||
- Custom template configuration | ||
- Dynamic parameter discovery | ||
- Advanced workflow setup | ||
|
||
## Response Formats | ||
|
||
Orshot supports multiple response formats: | ||
|
||
- **Base64**: Encoded image data for direct embedding | ||
- **Binary**: Raw image data for file operations | ||
- **URL**: Hosted image URL for immediate use | ||
|
||
## Supported Image Formats | ||
|
||
- PNG (default) | ||
- JPG/JPEG | ||
- WebP | ||
|
||
## Example Use Cases | ||
|
||
1. **Social Media Automation**: Generate personalized social media posts based on user data | ||
2. **E-commerce**: Create product images with dynamic pricing and offers | ||
3. **Marketing Campaigns**: Generate campaign materials with personalized content | ||
4. **Report Generation**: Create visual reports with dynamic charts and data | ||
5. **Content Personalization**: Generate user-specific images for emails and websites | ||
|
||
## Links | ||
|
||
- [Orshot Website](https://orshot.com) | ||
- [API Documentation](https://orshot.com/docs) | ||
- [Template Library](https://orshot.com/templates) | ||
- [Get API Key](https://orshot.com/workspace) |
139 changes: 139 additions & 0 deletions
139
...onents/orshot/actions/generate-image-library-template/generate-image-library-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import orshot from "../../orshot.app.mjs"; | ||
import { | ||
getMimeType, parseObject, | ||
} from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "orshot-generate-image-library-template", | ||
name: "Generate Image from Library Template", | ||
description: "Generate an image from a pre-designed library template using the Orshot API. [See the documentation](https://orshot.com/docs/api-reference/render-from-template)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
orshot, | ||
templateId: { | ||
propDefinition: [ | ||
orshot, | ||
"templateId", | ||
], | ||
}, | ||
responseType: { | ||
propDefinition: [ | ||
orshot, | ||
"responseType", | ||
], | ||
}, | ||
responseFormat: { | ||
propDefinition: [ | ||
orshot, | ||
"responseFormat", | ||
], | ||
}, | ||
modifications: { | ||
propDefinition: [ | ||
orshot, | ||
"modifications", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
templateId, | ||
responseType, | ||
responseFormat, | ||
modifications = {}, | ||
} = this; | ||
|
||
// Input validation | ||
if (!templateId) { | ||
throw new Error("Template ID is required"); | ||
} | ||
|
||
if (!responseType) { | ||
throw new Error("Response type is required"); | ||
} | ||
|
||
if (!responseFormat) { | ||
throw new Error("Response format is required"); | ||
} | ||
|
||
// Validate responseType | ||
const validResponseTypes = [ | ||
"base64", | ||
"binary", | ||
"url", | ||
]; | ||
if (!validResponseTypes.includes(responseType)) { | ||
throw new Error( | ||
`Invalid response type. Must be one of: ${validResponseTypes.join( | ||
", ", | ||
)}`, | ||
); | ||
} | ||
|
||
// Validate responseFormat | ||
const validFormats = [ | ||
"png", | ||
"jpg", | ||
"jpeg", | ||
"webp", | ||
]; | ||
if (!validFormats.includes(responseFormat.toLowerCase())) { | ||
throw new Error( | ||
`Invalid response format. Must be one of: ${validFormats.join(", ")}`, | ||
); | ||
} | ||
|
||
const validModifications = parseObject(modifications); | ||
|
||
try { | ||
const response = await this.orshot.generateImageFromLibraryTemplate({ | ||
$, | ||
data: { | ||
templateId, | ||
modifications: validModifications, | ||
response: { | ||
type: responseType, | ||
format: responseFormat, | ||
}, | ||
}, | ||
}); | ||
|
||
const result = { | ||
templateId, | ||
responseType, | ||
responseFormat, | ||
modifications: validModifications, | ||
timestamp: new Date().toISOString(), | ||
source: "orshot-pipedream", | ||
}; | ||
|
||
// Handle different response types | ||
switch (responseType) { | ||
case "base64": | ||
result.data = response.data; | ||
result.mimeType = getMimeType(responseFormat); | ||
break; | ||
case "binary": | ||
result.data = response; | ||
result.mimeType = getMimeType(responseFormat); | ||
break; | ||
case "url": | ||
result.data = response.data; | ||
break; | ||
default: | ||
result.data = response.data; | ||
} | ||
|
||
$.export( | ||
"$summary", | ||
`Successfully generated image from template ${templateId}`, | ||
); | ||
return result; | ||
} catch (error) { | ||
const errorMessage = error.message || "Unknown error occurred"; | ||
throw new Error(`Failed to generate image: ${errorMessage}`); | ||
} | ||
}, | ||
}; |
139 changes: 139 additions & 0 deletions
139
components/orshot/actions/generate-image-studio-template/generate-image-studio-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import orshot from "../../orshot.app.mjs"; | ||
import { | ||
getMimeType, parseObject, | ||
} from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "orshot-generate-image-studio-template", | ||
name: "Generate Image from Studio Template", | ||
description: "Generate an image from an Orshot Studio template using the Orshot API. [See the documentation](https://orshot.com/docs/api-reference/render-from-studio-template)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
orshot, | ||
templateId: { | ||
propDefinition: [ | ||
orshot, | ||
"studioTemplateId", | ||
], | ||
}, | ||
responseType: { | ||
propDefinition: [ | ||
orshot, | ||
"responseType", | ||
], | ||
}, | ||
responseFormat: { | ||
propDefinition: [ | ||
orshot, | ||
"responseFormat", | ||
], | ||
}, | ||
modifications: { | ||
propDefinition: [ | ||
orshot, | ||
"modifications", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
templateId, | ||
responseType, | ||
responseFormat, | ||
modifications = {}, | ||
} = this; | ||
|
||
// Input validation | ||
if (!templateId) { | ||
throw new Error("Template ID is required"); | ||
} | ||
|
||
if (!responseType) { | ||
throw new Error("Response type is required"); | ||
} | ||
|
||
if (!responseFormat) { | ||
throw new Error("Response format is required"); | ||
} | ||
|
||
// Validate responseType | ||
const validResponseTypes = [ | ||
"base64", | ||
"binary", | ||
"url", | ||
]; | ||
if (!validResponseTypes.includes(responseType)) { | ||
throw new Error( | ||
`Invalid response type. Must be one of: ${validResponseTypes.join( | ||
", ", | ||
)}`, | ||
); | ||
} | ||
|
||
// Validate responseFormat | ||
const validFormats = [ | ||
"png", | ||
"jpg", | ||
"jpeg", | ||
"webp", | ||
]; | ||
if (!validFormats.includes(responseFormat.toLowerCase())) { | ||
throw new Error( | ||
`Invalid response format. Must be one of: ${validFormats.join(", ")}`, | ||
); | ||
} | ||
|
||
const validModifications = parseObject(modifications); | ||
|
||
try { | ||
const response = await this.orshot.generateImageFromStudioTemplate({ | ||
$, | ||
data: { | ||
templateId, | ||
modifications: validModifications, | ||
response: { | ||
type: responseType, | ||
format: responseFormat, | ||
}, | ||
}, | ||
}); | ||
|
||
const result = { | ||
templateId, | ||
responseType, | ||
responseFormat, | ||
modifications: validModifications, | ||
timestamp: new Date().toISOString(), | ||
source: "orshot-pipedream", | ||
}; | ||
|
||
// Handle different response types | ||
switch (responseType) { | ||
case "base64": | ||
result.data = response.data; | ||
result.mimeType = getMimeType(responseFormat); | ||
break; | ||
case "binary": | ||
result.data = response; | ||
result.mimeType = getMimeType(responseFormat); | ||
break; | ||
case "url": | ||
result.data = response.data; | ||
break; | ||
default: | ||
result.data = response.data; | ||
} | ||
|
||
$.export( | ||
"$summary", | ||
`Successfully generated image from studio template ${templateId}`, | ||
); | ||
return result; | ||
} catch (error) { | ||
const errorMessage = error.message || "Unknown error occurred"; | ||
throw new Error(`Failed to generate image: ${errorMessage}`); | ||
} | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.