Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hand-of-doom/picsum-sdk
Lorem Picsum GO (Golang) SDK for generating random images
https://github.com/hand-of-doom/picsum-sdk
Last synced: about 11 hours ago
JSON representation
Lorem Picsum GO (Golang) SDK for generating random images
- Host: GitHub
- URL: https://github.com/hand-of-doom/picsum-sdk
- Owner: Hand-of-Doom
- License: unlicense
- Created: 2024-02-19T17:56:56.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-19T19:19:14.000Z (11 months ago)
- Last Synced: 2024-11-11T10:54:37.758Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Picsum-SDK
Picsum GO (Golang) SDK for generating random images
## How to install
```shell
go get github.com/Hand-of-Doom/Picsum-SDK@latest
```## Examples
### Generating a random image
```go
provider := picsum.NewImageProvider(
picsum.NewImageOptions(500, 500), // width & height
)image, err := provider.Load()
fmt.Println(image.ID) // id of that imageos.WriteFile("./output.jpg", image.Content, 0400)
```### Getting an image by seed
```go
options := picsum.NewImageOptions(500, 500).
Identifier("apple", picsum.Seed)provider := picsum.NewImageProvider(options)
image, err := provider.Load()os.WriteFile("./output.jpg", image.Content, 0400)
```### Getting an image by id
```go
options := picsum.NewImageOptions(500, 500).
Identifier("1", picsum.ID)provider := picsum.NewImageProvider(options)
image, err := provider.Load()os.WriteFile("./output.jpg", image.Content, 0400)
```### Getting an image with blur & grayscale filter
```go
options := picsum.NewImageOptions(500, 500)
// You can set blur depth to zero to disable blur effect
options.Filter(
/*is grayscale enabled*/ true,
/*blur depth*/ 5,
)provider := picsum.NewImageProvider(options)
image, err := provider.Load()os.WriteFile("./output.jpg", image.Content, 0400)
```### Getting images in different formats
```go
optionsWebP := picsum.NewImageOptions(500, 500).Format(picsum.WebP)optionsJPEG := picsum.NewImageOptions(500, 500).Format(picsum.JPG)
imageWebP, err := picsum.NewImageProvider(optionsWebP).Load()
imageJPEG, err := picsum.NewImageProvider(optionsJPEG).Load()os.WriteFile("./output.webp", imageWebP.Content, 0400)
os.WriteFile("./output.jpg", imageJPEG.Content, 0400)
```### Getting image details
```go
image, err := picsum.
NewImageProvider(picsum.NewImageOptions(500, 500)).
Load()thisImageID := image.ID
details, err := picsum.GetImageDetails(thisImageID, picsum.ID)
// By seed
details, err := picsum.GetImageDetails("apple", picsum.Seed)
```### Getting a list of images
```go
page := 1
limit := 100
list, err := picsum.GetImagesList(page, limit)if list.LastPage {
fmt.Println("Oh, this is a last page!")
}fmt.Println(list.Value)
```