npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-synaps-pics

v0.4.2

Published

[![NPM Package](https://badge.fury.io/js/ngx-synaps-pics.svg)](https://npmjs.org/package/ngx-synaps-pics) [![Build Status](https://travis-ci.org/synapshq/ngx-synaps-pics.svg?branch=master)](https://travis-ci.org/synapshq/ngx-synaps-pics) [![semantic-relea

Downloads

23

Readme

ngx-synaps-pics

NPM Package Build Status semantic-release

Angular bindings for Synaps.Pics

Installation

With npm:

npm i --save ngx-synaps-pics

With yarn:

yarn add ngx-synaps-pics

Usage

Import SynapsPicsModule to your app.

import { SynapsPicsModule } from 'ngx-synaps-pics';

@NgModule{
  ....
  imports: [
    ...,
    SynapsPicsModule
  ],

Now you can use synapsPics directive in your templates.

<img [synapsPics]="imageUrl" width="100" height="100" crop="fill">

Using as background

By default, synapsPics directive sets the image url for src and/or srcset attribute. If you want to use image as a background you can use as-background attribute.

<div [synapsPics]="imageUrl" width="100" height="100" as-background></div>

Using as an attribute

You can also set url as an attribute:

<a [synapsPics]="imageUrl" width="100" height="100" crop="fill" as-attr="href">Link to image</a>

Lazy Loading

ngx-synaps-pics has the ability lazy loading images with a given condition or by checking if it's in the viewport.

Lazy load image when it's visible

<img [synapsPics]="imageUrl" lazy>

Please note that, visibility checking is using Intersection Observer API. If you need to support Internet Explorer and Safari browsers please include intersection observer pollyfill to your page. Just run npm i --save intersection-observer and then add import 'intersection-observer'; line to your pollyfill.ts file.

Lazy loading with a condition

[lazy] attribute also accepts a boolean value. So you can write some conditions for defining when image will be loaded. This feature is handy when you want to use it with a slider/carousel component for example.

<div class="slide" *ngFor="let slide of slides; let i = index">
  <img [synapsPics]="imageUrl" [lazy]="activeSlide === i">
</div>

Reference for manipulation parameters

For the original image below available manipulation parameters and example results are here.

parameter | value | example | Description --- | --- | --- | --- width | (integer) | | sets width: <img [synapsPics]="'/anon/image_bla.jpg'" width="80"> height | (integer) | | sets height: <img [synapsPics]="'/anon/image_bla.jpg'" height="80"> crop | fit (default) | | The image is resized so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. The original aspect ratio is retained and all of the original image is visible.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fit"> crop | scale | | Change the size of the image exactly to the given width and height without necessarily retaining the original aspect ratio: all original image parts are visible but might be stretched or shrunk.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="scale"> crop | fill | | Same as the 'fit' mode but only if the original image is larger than the given limit (width and height), in which case the image is scaled down so that it takes up as much space as possible within a bounding box defined by the given width and height parameters. The original aspect ratio is retained and all of the original image is visible.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill"> crop | pad | | Resize the image to fill the given width and height while retaining the original aspect ratio. If the proportions of the original image do not match the given width and height, padding is added to the image to reach the required size.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="pad"> crop | limit | | Same as the 'fit' mode but only if the original image is larger than the given limit (width and height).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="limit"> quality | integer (default 80) | | Output quality. 1 to 100.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" q="40"> gravity | center (default) | | The focus to the center of the image when cropping.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="center"> gravity | northwest | | The focus to the northwest of the image when cropping.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="northwest"> gravity | northeast | | North east corner (top right).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="northeast"> gravity | southeast | | South east corner (bottom right).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="southeast"> gravity | southwest | | South west corner (bottom left).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="southwest"> gravity | north | | North center part (top center).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="north"> gravity | west | | Middle west part (left).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="west"> gravity | east | | Middle east part (right).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="east"> gravity | south | | Middle south part (bottom center).<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="south"> gravity | auto | | Smart cropping with feature detection.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="fill" gravity="auto"> background | ffffff | | Fill background color for pad crop style.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" crop="pad" bg="ffffff"> format | jpg,png,gif,webp | | Set the output image format.<img [synapsPics]="'/anon/image_bla.jpg'" width="80" height="80" format="gif">

Thanks

Special thanks to BrowserStack for their support about testing our work on multiple platforms.