Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rocketbase-io/imgproxy-java

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgproxy-java

logo

build Maven Central

fluently generate asset urls for img-proxy within java

  • dependency-free at runtime
  • requires Java 11+
  • supports signed and unsigned imgproxy URLs
  • supports official imgproxy hex key/salt configuration
  • supports both encoded and /plain/ source URLs

example usage

// unsigned
String url = Signature.of(SignatureConfiguration.unsigned(BASE_URL))
                .size(300, 300)
                .url(SOURCE_URL)

configuration

// official imgproxy configuration:
// key and salt are the hex-encoded values from IMGPROXY_KEY / IMGPROXY_SALT
SignatureConfiguration signedConfiguration = SignatureConfiguration.signed(
                imgproxyProperties.getBaseurl(),
                imgproxyProperties.getKey(),
                imgproxyProperties.getSalt());

// raw/plain-text fallback:
// only use this if you already have raw key/salt bytes
SignatureConfiguration rawConfiguration = SignatureConfiguration.signedRaw(
                imgproxyProperties.getBaseurl(),
                keyBytes,
                saltBytes);

further usages

String resizedUrl = Signature.of(signedConfiguration)
                .resize(ResizeType.fit, 300, 300, true)
                .url("s3://bucket-name/" + assetReference.getUrlPath());

// exact 75x75 thumbnail, cropped around the smart focal area
String thumbUrl = Signature.of(signedConfiguration)
                .resize(ResizeType.fill, 75, 75, false, false)
                .gravity(GravityType.sm)
                .url("s3://bucket-name/path/image.jpg", ImageType.webp);

// keep the whole image visible inside 300x300 and fill the remaining area with white
String containUrl = Signature.of(signedConfiguration)
                .resize(ResizeType.fit, 300, 300, false, true)
                .background("FFFFFF")
                .url("s3://bucket-name/path/image.jpg", ImageType.webp);

// useful if you don't want the source URL base64-encoded in the path
String plainUrl = Signature.of(signedConfiguration)
                .resize(ResizeType.fit, 1200, 800, true)
                .quality(85)
                .urlPlain("https://cdn.example.org/images/photo.jpg?version=42", ImageType.jpg);

About

fluently generate asset urls for img-proxy within java

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.