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

simple-cloudinary

v0.5.1

Published

Simple way tu use Cloudinary API by javascript Class object with TypeScript

Downloads

8

Readme

Simple Cloudinary !

This is an abstraction of cloudinary api to improve development by TypeScript object.

Thirst, you must create an account to Cloudinary cloudinary And after... Enjoy !


How to use ?

Install module :

npm install --save damiengilbrin/cloudinary-transformation

Require a cloudinary object and his configuration like Cloudinary documentation - Nodejs intégration

let cloudinary = require('cloudinary');
cloudinary.config({
    cloud_name: 'sample',
    api_key: '874837483274837',
    api_secret: 'a676b67565c6767a6767d6767f676fe1'
});

Upload file to cloudinary (see Cloudinary documentation)

Make an instance of simpleCloudinary :

let simpleCloudinary = require('./index')(cloudinary);

Make an image by Json Object

If you want you can put an object configuration like Json :

let imageUrl = simpleCloudinary.createFromJsonObject(
    'MyImageNameUploadedToCloudinary',
    [
        {
            type: 'rotate',
            enabled: true,
            parameters: {
                angle: -30
            }
        },
        {
            type: 'crop',
            enabled: true,
            parameters: {
                x: 10,
                y: 50,
                width: 500,
                height: 400
            }
        }
    ],
    {
        text: 'Created by Damien Gilbrin',
        fontSize: 15,
        fontFamily: 'Trebuchet MS',
        fontStyle: 'normal',
        fontWeight: 'bold',
        fontColor: {
            red: 255,
            green: 255,
            blue: 255,
            alpha: 1
        },
        backgroundColor: {
            red: 0,
            green: 0,
            blue: 0,
            alpha: 0.75
        },
        gravity: {
            direction: 'south_west',
            offset_x: 10,
            offset_y: 10
        }
    }
).getUrl(200,200)

createFromJsonObject(imageId, transformations, signature) : UrlGenerator

Functions parameters :

  • imageId (string) : Name of image on cloudinary
  • transformations (array of object) : A collection of transformation
  • signature(object|false) : a signature object to make a signature or false if no sign Will return an object a UrlGenerator class

transformation Objects parameters :

  • type (string) : type of transformation :
    • 'rotate' to rotate an image. The parameters parameters must have this :
      • angle (number) : degres of rotate
    • 'crop' to cut an image from x and y point and width and height. The parameters parameters must have this :
      • x (number) : Start position to cut image x
      • y (number) : Start position to cut image y
      • width (number) : Width of new image crop from x
      • height (number) : Height of new image crop from y
  • enabled (boolean) : If true, the current transormation is apply
  • parameters (object) : List of parameters of transformation, see type for more informations

signature Objects parameters :

  • text (string) : Message of signature, eq "Created by Damien Gilbrin"
  • fontSize (nulmber) : Font size at pixel
  • fontFamily (string) : Font family name, eq "Arial"
  • fontStyle (string) : A font style like "italic"
  • fontWeight (string) : A font weight like "bold"
  • fontColor (object) : A color object of font coloration
  • backgroundColor (object) : A color object of background coloration
  • gravity (object) : a gravity object

color Objects parameters :

  • red (number) : A red color 0 to 255
  • green (number) : A red color 0 to 255
  • blue (number) : A red color 0 to 255
  • alpha (number) : A rate of alpha 0 to 1. (1 is totaly visible)

gravity Objects parameters :

  • direction (string) : Name of direction gravity : 'south_west', 'south', 'south_east', 'north_west', 'north', 'north_east'
  • `offset_x (number) : Offset x of gravity, default 0 pixel
  • `offset_y (number) : Offset y of gravity, default 0 pixel

UrlGenerator class :

This class containe this method : getUrl(width: number, height: number): string

You call this methode to generate an Url for this configuration width and height pixel. It will return a signed url string of cloudinary


createFromImageObject(imageId) : ImageManipulation

(documentation soon)