TwicPics is powered by a URL-based API that can be used to transform and manipulate images.
In order to perform an API call to TwicPics you need to provide:
As seen in the subdomain section, your source image will be accessible through
The manipulation part can be provided in a query string of the following form:
<manipulation> is a list of one or more transformations separated by the character
So the final URL format is as follows:
For instance, provided the root (
/) of subdomain
sub points to
https://sub.twic.pics/myImage.png?twic=v1/resize=450 will redimension
http://mydomain.com/myimage.png to a width of 450 pixels while preserving its aspect ratio.
If you wish to pass query parameters to the server delivering the source image, just add it to the query string before or after the manipulation using the usual query string separator
Going back to the previous example but, this time, wanting to manipulate
http://mydomain.com/myimage.png?param=value you could use one of these two options:
While the format presented in the previous section is the preferred one and should always be used when making direct API calls to manipulate images, there exists an alternative.
The alternative format goes as follows:
<source_image> is one of:
https://sub.twic.pics/v1/resize=640x480/placeholder:autowill generate a 640 pixels wide per 480 pixels high gray colored placeholder
https://sub.twic.pics/v1/resize=450/image:myImage.png?param=valueis strictly equivalent to the
https://sub.twic.pics/myImage.png?twic=v1/resize=450&param=valueexpression seen in the previous section
When using the Script, which will automatically issue API calls for you using this very alternative format, please remember to use a
<source_image>-compatible expression inside any
data-background attribute you may provide. That is:
Whenever something goes wrong, TwicPics will issue an HTTP error with a sensible status code and a short explanation in plain text as a body.
TwicPics will error when:
GETrequest to retrieve it resulted in an HTTP error)
Whenever an image does not show in your web page, be sure to check the network tab of your favorite dev tool for those red-colored lines indicative of a network error.