SIMSI 4

Installation & Configuration

How to configure & install the Sophora Image Service.

Installation

For running Access Service and Update Service in a cloud environment, we provide docker images and helm charts on our docker registry.
Be sure to mount your specific application.yml, (if desired also logback-spring.xml) into the containers at /app/config.

If you would not like to use docker, locate your configuration files next to the jar-file. A rudimentary startup command for Access- and Update Service could look as follows:

 java -jar sophora-image-access-service-4.x.x.jar
 java -jar sophora-image-update-service-4.x.x.jar

Configuration

Sophora Image Access- and Update Services are Spring Boot applications and is therefore configurable by using an application.yml file or through matching environment variables.

Configuration Image Update Service & Image Access Service

Image Access Service and Image Update Service have following configuration properties in common, hence they are documented once here. See also component-specific configuration below.

PropertyDescriptionDefault
spring.profiles.activeThe active spring profile has an influence on the default logging behavior. With "prod" active, logs are printed with JSON-format.prod
server.portServer port of the application
endpoints.web.exposure.includeDefault Spring and custom endpoints that will be available to check certain application metrics under /actuator.sophoraserver, info, health, jolokia, threaddump, prometheus
sophora.image-service.s3-image-store.hostThe host URL of the image store, i.e. https://storage.googleapis.com
sophora.image-service.s3-image-store.access-key-idAccessKeyId for accessing the storage bucket
sophora.image-service.s3-image-store.secret-access-keySecretAccessKey for accessing the storage bucket
sophora.image-service.s3-image-store.bucket-nameThe storage bucket name
sophora.image-service.s3-image-store.create-bucketThis property should always be false in production. It can be helpful to automatically create a non-existent bucket during development.false
sophora.client.server-connection.urlsThe Sophora Servers to connect with. The Update Service should connect to the Primary Server, Acces Services (except for preview) should connect to Replica Servers.
sophora.client.server-connection.usernameUsername for Client connection to the Sophora Server
sophora.client.server-connection.passwordPassword for Client connection to the Sophora Server

Configuration Image Access Service

PropertyDescriptionExampleDefault
sophora.image-service.image-access-service.live-modeWhether to deliver either only pulished images or only working version imagestrue/false
sophora.image-service.image-access-service.lock-cache-cleanup-interval5s
sophora.image-service.image-access-service.long-cache-durationCache duration for stable images (in contrast to short-cache-duration)1d (1 day)
sophora.image-service.image-access-service.short-cache-durationCache duration for instable images that might not be up to date at request time due to replication latency1m (1 minute)
sophora.image-service.image-access-service.image-generation-warning-thresholdThreshold (in ms) for normally expected image binary data generation. When generation time exceeds this value, a log message with image details and generation time will be logged with level WARN. Otherwise, the loglevel for this message is DEBUG10001500
sophora.image-service.image-access-service.image-scaling-enabledWhether the access service should allow the parameters width or height for dynamic scaling of images.true/falsefalse
sophora.image-service.image-access-service.generation.metadata.remove-allDetermines how EXIF and IPTC metadata from uploaded/imported binary data is handled
  • true: existing EXIF/IPTC metadata will be removed
  • false: existing EXIF/IPTC metadata is preserved
  • unset: existing EXIF/IPTC metadata is preserved, when neither iptc nor exif is set
This value can only be set if properties iptc and exif are not set, otherwise the configuration is considered invalid!
true/falseunset
sophora.image-service.image-access-service.generation.metadata.iptcList of IPTC-IIM tag names that should be written into delivered image variants, only supported tag names are allowed.
For more information about IPTC-IIM, visit the Wikipedia page.
A complete list with all supported tag names and their IPTC-Code can be found in Appendix A.
If this property is empty, but metadata handling is enabled (i.e. remove-all is true or exif is set), delivered image variants will have no IPTC-IIM metadata.
- Credit
- City
unset
sophora.image-service.image-access-service.generation.metadata.exifList of EXIF tag names that should be written into delivered image variants, only supported tag names are allowed.
For more information about Exif tags, visit the Wikipedia page.
A complete list with all supported tag names and their ID can be found at the Appendix B.
If this property is empty, but metadata handling is enabled (i.e. remove-all is true or iptc is set), delivered image variants will have no EXIF metadata.
- Copyrightunset

Configuration Image Update Service

PropertyDescriptionDefault
sophora.image-service.image-event-listener.ping-eventThe duration after which a synthetic ping event is queued if no image-related event occurred during this time. This lets the Update Service know since when it could have missed any events that should be reconsidered in case of downtime.30s
sophora.image-service.image-event-worker.max-retriesIn case of a failure on image event handling, this value declares the max. number of retries that should be performed. If value is 0, no retry will occur at all.3
sophora.image-service.image-event-worker.thread-countThe number of threads to be used for handling image-related events.2
sophora.image-service.image-event-worker.retry-delays-msA list of delays for image event retry process. In default, the first retry will be after 1000ms, the second retry after 2500ms, every next retry 6000ms1000, 2500, 6000
sophora.image-service.image-event-worker.connection-test-retry-intervalThe duration to wait between connection checks if either the Sophora Server or the image store cannot be reached.10s
sophora.image-service.image-event-worker.update-last-processed-timestamp-grace-periodGrace period before a new lastProcessedTimestamp is persisted in the cloud storage.10s
sophora.image-service.cleanup.cron-trigger-expressionThe Cron expression for the interval when the Update Service should check for old data. The special value "-" indicates that no cleanup shall be performed.0 0 0 * * ? (every day at 00:00:00)
sophora.image-service.cleanup.minimum-age-daysThe minimum age of the data in days before it will be removed from the S3 storage.30

Image Service URL builder

A simple way to create URLs for delivering images and other Sophora documents is the usage of the Sophora URL Library.

If you want to use additional image URL features (e.g. image width or height), you should use the ImageUrlBuilder from the Sophora Image Service. For a working example we assume that you are using the Spring Boot framework for your application. Please ask for support if you need assistance for a different setup.

To create Sophora Image Service URLs in your Spring Boot application, you need at least the following three dependencies. If you use the Sophora URL Library for other URLs, the dependencies are already in your classpath:

[...]
<dependency>
	<groupId>com.subshell.sophora</groupId>
	<artifactId>spring-boot-sophora-commons</artifactId>
	<version>4.x.x</version>
</dependency>

<dependency>
	<groupId>com.subshell.sophora</groupId>
	<artifactId>com.subshell.sophora.api</artifactId>
	<version>4.x.x</version>
</dependency>

<dependency>
	<groupId>com.subshell.sophora.imageservice</groupId>
	<artifactId>sophora-image-url-client</artifactId>
	<version>4.x.x</version>
</dependency>
[...]

You also have to setup the classpath scanning of your application to additionally include the two packages com.subshell.sophora.springbootsophoracommons and com.subshell.imageurlbuilder:

@SpringBootApplication(scanBasePackages = {"com.subshell.sophora.springbootsophoracommons", "com.subshell.imageurlbuilder", "<your-application-package>"})
public class Application {

	public static void main(String[] args) {
		new SpringApplicationBuilder(Application.class)
				.run(args);
	}

}

Finally, you need to setup the Sophora Server connection for the Sophora client and the configuration for the Sophora Image Service URL Builder. For a minimal setup, add the following properties to the application.yml file. A comprehensive description for all configuration properties can be found in the URL configuration section of the Sophora URL Library documentation.

sophora:
  client:
    server-connection:
      username: "<user>"
      password: "<pwd>"
      urls: ["<sophora-server-url>"]

      
  image-service:
    url:
      default-domain: "https://<your-image-service>"

Now you can use Spring's dependency injection to get a configured ImageUrlBuilderProvider.
The following class:

@Component
public class CreateUrls {

	private static final Logger LOG = LoggerFactory.getLogger(CreateUrls.class);
	private final ImageUrlBuilderProvider builderProvider;

	public CreateUrls(ImageUrlBuilderProvider builderProvider) {
		this.builderProvider = builderProvider;
	}

	@PostConstruct
	void init() {
		UUID uuid = UUID.fromString("<image-uuid>");
		String url = builderProvider.forUuid(uuid)
				.build()
				.orElse(null);
		LOG.info("Image url: {}", url);
	}

}

will create this url:

12:37:30.185 INFO -  CreateUrls.init(CreateUrls.java:26) - Image url: https://<your-image-service>/image/<image-uuid>/AAABiNlHWSg/AAABiQIJgMc/original.jpg

The ImageUrlBuilder generated by the ImageUrlBuilderProvider also assists to use other features of the Sophora Image Service. The following code creates a URL with an overlay, image format webp and a specific width:

 UUID uuid = UUID.fromString("<image-uuid>"); 
 String url = builderProvider.forUuid(uuid) 
 .withSlug("interesting-image")
 .withSuffix("webp")
 .withOverlayImage("overlay-image-external-id")
 .withVariantName("16x9")
 .withWidth(1280)
 .build()
 .orElse(null);

The created URL will look like this:

https://<your-image-service>/image/<image-uuid>/AAAAAEmWAtI/AAAAAAAAMDk/16x9/interesting-image.webp?overlay=<overlay-uuid>&overlayModificationDate=AAAAAAA3D3C&width=1280

Appendix A: Supported IPTC-IIM tag names and IPTC-Codes

  1. By-line (2:80)
  2. By-line Title (2:85)
  3. Caption/Abstract (2:120)
  4. Category (2:15)
  5. City (2:90)
  6. Contact (2:118)
  7. Copyright Notice (2:116)
  8. Country/Primary Location Code (2:100)
  9. Country/Primary Location Name (2:101)
  10. Credit (2:110)
  11. Date Created (2:55)
  12. Digital Creation Date (2:62)
  13. Edit Status (2:7)
  14. Expiration Date (2:37)
  15. Expiration Time (2:38)
  16. Fixture Identifier (2:22)
  17. Headline (2:105)
  18. Image Orientation (2:131)
  19. ImageType (2:130)
  20. Keywords (2:25)
  21. Language Identifier (2:135)
  22. Object Attribute Reference (2:4)
  23. Object Cycle (2:75)
  24. Object Data Preview Data (2:202)
  25. Object Data Preview, File Format (2:200)
  26. Object Data Preview, File Format Version (2:201)
  27. Object Name (2:5)
  28. Original Transmission, Reference (2:103)
  29. Originating Program (2:65)
  30. Program Version (2:70)
  31. Province/State (2:95)
  32. Rasterized Caption (2:125)
  33. Reference Date (2:47)
  34. Reference Number (2:50)
  35. Reference Service (2:45)
  36. Release Date (2:30)
  37. Release Time (2:35)
  38. Source (2:115)
  39. Special Instructions (2:40)
  40. Subject Reference (2:12)
  41. Sublocation (2:92)
  42. Supplemental Category (2:20)
  43. Time Created (2:60)
  44. Urgency (2:10)
  45. Writer/Editor (2:122)

Appendix B: Supported Exif tag names and IDs

  1. Artist (0x13B)
  2. BitsPerSample (0x102)
  3. BodySerialNumber (0xA431)
  4. BrightnessValue (0x9203)
  5. CFAPattern (0xA302)
  6. CameraOwnerName (0xA430)
  7. ColorSpace (0xA001)
  8. ComponentsConfiguration (0x9101)
  9. CompressedBitsPerPixel (0x9102)
  10. Contrast (0xA408)
  11. Copyright (0x8298)
  12. CustomRendered (0xA401)
  13. DateTime (0x132)
  14. DateTimeDigitized (0x9004)
  15. DateTimeOriginal (0x9003)
  16. DeviceSettingDescription (0xA40B)
  17. DigitalZoomRatio (0xA404)
  18. DocumentName (0x10D)
  19. ExifImageWidth (0xA002)
  20. ExifVersion (0x9000)
  21. ExposureIndex (0xA215)
  22. ExposureMode (0xA402)
  23. ExposureProgram (0x8822)
  24. ExposureTime (0x829A)
  25. FNumber (0x829D)
  26. FileSource (0xA300)
  27. Flash (0x9209)
  28. FlashEnergy (0xA20B)
  29. FlashpixVersion (0xA000)
  30. FocalLength (0x920A)
  31. FocalPlaneResolutionUnit (0xA210)
  32. FocalPlaneXResolution (0xA20E)
  33. FocalPlaneYResolution (0xA20F)
  34. GainControl (0xA407)
  35. Gamma (0xA500)
  36. ImageDescription (0x10E)
  37. ImageNumber (0xA211)
  38. InteroperabilityIndex (0x1)
  39. InteroperabilityVersion (0x2)
  40. Lens (0xFDEA)
  41. LensMake (0xA433)
  42. LensModel (0xA434)
  43. LensSerialNumber (0xA435)
  44. LensSpecification (0xA432)
  45. Make (0x10F)
  46. MaxApertureValue (0x9205)
  47. MeteringMode (0x9207)
  48. Model (0x110)
  49. Orientation (0x112)
  50. PrimaryChromaticities (0x13F)
  51. ReferenceBlackWhite (0x214)
  52. RelatedImageLength (0x1002)
  53. RelatedImageWidth (0x1001)
  54. RelatedSoundFile (0xA004)
  55. ResolutionUnit (0x128)
  56. Saturation (0xA409)
  57. SceneCaptureType (0xA406)
  58. SceneType (0xA301)
  59. SensingMethod (0xA217)
  60. Sharpness (0xA40A)
  61. ShutterSpeedValue (0x9201)
  62. Software (0x131)
  63. SubSecTime (0x9290)
  64. SubSecTimeDigitized (0x9292)
  65. SubSecTimeOriginal (0x9291)
  66. SubjectDistanceRange (0xA40C)
  67. SubjectLocation (0xA214)
  68. TimeZoneOffset (0x882A)
  69. UserComment (0x9286)
  70. WhiteBalance (0xA403)
  71. WhitePoint (0x13E)
  72. XPAuthor (0x9C9D)
  73. XPComment (0x9C9C)
  74. XPKeywords (0x9C9E)
  75. XPSubject (0x9C9F)
  76. XPTitle (0x9C9B)
  77. XResolution (0x11A)
  78. YResolution (0x11B)
  79. YCbCrCoefficients (0x211)
  80. YCbCrPositioning (0x213)

Last modified on 6/19/23

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon