Codebank

Post tagged with “images”

Create a row of equal height images that have different aspect ratios

Article here

Static images in the sm:image tag

This is how you can reference a static image asset inside the <sm:image /> tag, which can be useful when defining fallback images etc.

<sm:image value="/static/img/home-hero-placeholder.png" staticAsset="true" ... />

Use Terminal to base64 encode an image

Generate base64 version of an image:

openssl base64 < path/to/file

Do the same, but remove line breaks:

openssl base64 < path/to/file.png | tr -d '\n'

Do the above, but copy the result to the clipboard:

openssl base64 < path/to/file.png | tr -d '\n' | pbcopy

Imagemagick command to assemble images into a sprite

Change the dimensions and tile layout to suit the size of images and number of rows/columns you desire.

montage -background transparent -geometry 1500x344+0+0 -tile 4x13 *.png sprite3.png