- Install Options
- Basic Usage
- Signed URLs
- Srcset Generation
- Running Tests
The library itself has no external dependencies. Although if you want to build from source (or run tests) then you need
ant and the
Gradle & JCenter
To add Imgix-Java to your project, include the following in your project's build.gradle:
And if this is your first external JCenter dependency you'll need to add, again to your project level build.gradle, the following:
Creating a Jar
To create a jar from source:
Once a new version has been merged into master on GitHub (don't forget to update the version numbers in build.gradle first!), it can be deployed to Bintray with
gradle build && gradle bintrayUpload. After that, the new version can be viewed via the Bintray web interface.
To begin creating imgix URLs programmatically, simply add the jar to your project's classpath and import the imgix library. The URL builder can be reused to create URLs for any images on the domains it is provided.
For HTTPS support, simply use the setter
setUseHttps on the builder
To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.
The imgix-java library allows for generation of custom
srcset attributes, which can be invoked through
createSrcSet(). By default, the
srcset generated will allow for responsive size switching by building a list of image-width mappings.
Will produce the following attribute value, which can then be served to the client:
In cases where enough information is provided about an image's dimensions,
createSrcSet() will instead build a
srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are
h (height), and
ar (aspect ratio). By invoking
createSrcSet() with either a width or the height and aspect ratio (along with
fit=crop, typically) provided, a different
srcset will be generated for a fixed-size image instead.
Will produce the following attribute value:
For more information to better understand
srcset, we highly recommend Eric Portis' "Srcset and sizes" article which goes into depth about the subject.
To run tests clone this project and run:
Dependencies for running tests (junit, etc) are provided (in
test/lib and referenced in the build config).
More Core Libraries
- imgix-csharpbuildA C# client library for generating image URLs with imgixC# 12 2 months ago
- imgix-elixirbuildAn Elixir client library for generating image URLs with imgixElixir 29 a month ago
- imgix-gobuildA Go client library for generating image URLs with imgixGo 2 2 months ago
- imgix-phpbuildA PHP client library for generating URLs with imgixPHP 90 2 months ago
- imgix-pythonbuildA Python client library for generating URLs with imgixPython 24 a month ago
- imgix-rbbuildA Ruby gem for generating image URLs with imgixRuby 63 2 months ago
- imgix-swiftbuildA Swift client library for generating URLs with imgixSwift 19 14 days ago