Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (47 sloc) 2.55 KB
For height and width you have two options. Setting it in your HTML or using the API to crop your images on the fly. For perfect images, we recommend a combination of both.

Setting height and width

Setting height/width within your HTML

The API will auto crop your image to the height/width of the outermost HTML element. For example, the following will generate a screenshot that is 400px wide and 400px tall.

{% code-tabs %} {% code-tabs-item title="height_width_example.html" %}

<div style="height: '400px'; width: '400px'">
  <h1>Hello, world</h1>

{% endcode-tabs-item %} {% endcode-tabs %}

Margins are respected by the API. To add padding around your image, you can do the following.

{% code-tabs %} {% code-tabs-item title="with_margin.html" %}

<div style="height: '400px'; width: '400px'; margin: 10px; border: 5px solid #03B875;"> 
  <h1>Hello, world</h1>

{% endcode-tabs-item %} {% endcode-tabs %}

Performance considerations

For best performance, we recommend a maximum of 2000x2000 pixels in your HTML. This will result in a 4000x4000 pixel image (because we render everything @2X for retina screens).

We dedicate 2gb of RAM for every rendered image. Going above 2000x2000 can cause Chrome to use more than 2gb of RAM when rendering your image.

{% hint style="info" %}

Retina by default

We render all images @2X by default. This results in a super high quality image that will work with any monitor. When specifying 400px in your HTML, the resulting image will be 800px to account for high res screens. {% endhint %}

Resize on the fly

Once an image is generated, use our API to adjust the image to any size you need with the width and height params. When only one param is passed, the API will maintain the aspect ratio of the original image.

This is useful for displaying images at different resolutions without having to setup your own CDN.







{% hint style="info" %} Resized images will be automatically cached by the CDN as well. You can use these URLs directly on your webpages and expect lightning fast response times + optimization for SEO. {% endhint %}