1.0.9 • Published 1 month ago

photosynth-react v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

PhotoSynth Component for React

This component provides a declarative interface to the PhotoSynth service for rendering images.

Installation

npm i photosynth-react

Setup

A PhotoSynth key is required and may be passed to the component as the prop psKey or set with the environment variable REACT_APP_PHOTOSYNTH_KEY. The latter is preferred to avoid passing in the psKey prop to every instance.

Sign up for a free key at https://temperal.co/

Props

NameRangeDefaultTypeDescription
adaptiveHistogram0 - 100intAdaptive histogram level of brightening
blur0.02 - 20.0floatBlur strength
brightness0.0 - 20.0floatBrightness multiplier
bypassfalsybooleanLoad sourceUrl directly without using PhotoSynth
cacheBustfalsyboolean, stringIf true, bust the cache with random query param. If string, use value as the param value.
cropBottomPercent1 - 99intCrop bottom percentage
cropLeftPercent1 - 99intCrop left percentage
cropRightPercent1 - 99intCrop right percentage
cropTopPercent1 - 99intCrop top percentage
formatwebpFormatType"avif", "gif", "jpeg", "png", "tiff", "webp"
gamma1.0 - 3.01floatGamma
greyscalefalsybooleanGreyscale (true/false)
height1 - 5000intGenerated image height
hue0.0 - 180.0floatHue shift
lightness0.0 - 200.0floatLightness addition
normalizeLower1 - 99intNormalization lower percentile threshold
normalizeUpper1 - 99intNormalization upper percentile threshold
psKeystringPhotoSynth key (Required if REACT_APP_PHOTOSYNTH_KEY not set)
saturation0.0 - 20.0floatSaturation level
sharpen0.1 - 10.0floatSharpening level
sourceUrlstringURL of the source image (Required)
width1 - 5000intGenerated image width

An additional prop cssStyle may be provided to customize the element's behavior. The value is merged with the default:

{
  backgroundPosition: "center",
  backgroundRepeat: "no-repeat",
  backgroundSize: "contain",
  height: "100%",
  width: "100%",
}

Example

import { PhotoSynth } from "photosynth-react";
...

  <PhotoSynth
    adaptiveHistogram={2}
    blur={0.02}
    brightness={1.0}
    cropBottomPercent={10}
    sourceUrl="https://some.domain/path/to/picture"
    cssStyle={{
      backgroundSize: "cover"
    }}
  />

Note that when width is omitted, the image auto sizes to its container's width.

Usage with other frameworks

The generateUrl() method is exposed and accepts an object with the same keys as documented above. The resulting URL may be passed as the src attribute of the <img> tag or the CSS value background-image: "url(GENERATED_URL)".

Notes

If the image processing fails, the original image URL will be displayed. Please contact support at https://temperal.co with the error details.

1.0.9

1 month ago

1.0.8

1 month ago

1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

3 months ago

1.0.3

4 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago