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

astro-cloudinary-image

v0.0.6

Published

Adds a Cloudinary image component to Astro

Downloads

63

Readme

astrocloudinary

🚀 Astro Cloudinary Image

This Astro component makes it easy to wrap the Cloudinary URL Generator library to dynamically generate and optimize images from the Cloudinary service.

Pull requests and/or feature requests are very welcome!

🔥 Motivation

This project aims to participate in @midudev hackathon: Cloudinary CloudCreate, in collaboration with Cloudinary.

💻 Features

Below is a short list of features that Astro Cloudinary Image offers.

  • Crops the image to fit the specified dimensions.
  • Scales the image to fill the specified dimensions.
  • Scales the image to the specified dimensions.
  • Scales the image to fit within the specified dimensions.
  • Generates a thumbnail of the image.
  • Centers the image around detected faces.
  • Automatically detects the subject of the image and centers it.
  • Add corner radius from 1px to max (round image)
  • Rotate the image
  • Applies various effects to the image.

🛠️ Installation

To install Astro SEO, run the following command in your terminal:

npm install astro-cloudinary-image

or if you use yarn:

yarn add astro-cloudinary-image

💻 How To Use

  1. First of all you have to create a

In any of your Astro projects, you need to create a .env file and add your cloud name on Cloudinary, like:

CLOUDINARY_CLOUD_NAME=XXXXXXX

Where XXXXXXX is your cloud name. Tip: You can find your Cloudinary Cloud Name right on the main Dashboard of your account.

  1. In any of your Astro pages, import Cloudinary and then use the component like:
---
import { Cloudinary } from 'astro-cloudinary-image';
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content={Astro.generator} />
    <title>Astro</title>
  </head>
  <body>  
    <Cloudinary 
      width="800"
      height="400"
      resize="fill"
      gravity="face"
      cornerRadius="max"
      rotate={20}
      effects={["backgroundRemoval", "sepia"]}
      alt="A sample image"
      src="cld-sample" 
      errorImage="NotFound.svg"
    />
  </body>
</html>

🗺️ Mandatory Props

  1. src: string - The URL of the image to be displayed. This src can be a full image url or the Cloudinary identifier on your media library

  2. alt: string - The alt text for the image.

  3. errorImage: string - A URL for a fallback image to display if the src image fails to load.

🗺️ Optional Props

  1. width?: string; - Sets the width of the image. It accepts a string value that can be a number in pixels (e.g. "100", "50").

  2. height?: string; - Sets the height of the image. It accepts a string value that can be a number in pixels (e.g. "100", "50").

  3. resize?: - Specifies the resizing behavior of the image. It can have one of the following values:

Resize | Option Description ------------ | ------------- "crop" | Crops the image to fit the specified dimensions. "fill" | Scales the image to fill the specified dimensions. "scale" | Scales the image to the specified dimensions. "minimumPad" | Scales the image to fit within the specified dimensions, adding padding if necessary. "fit" | Scales the image to fit within the specified dimensions. "limitFit" | Scales the image down to fit within the specified dimensions, but doesn't scale it up. "thumbnail" | Generates a thumbnail of the image. "limitFill" | Scales the image up or down to fill the specified dimensions, but doesn't crop it. "minimumFit" | Scales the image up or down to fit within the specified dimensions, but doesn't scale it beyond its original size. "limitPad" | Scales the image down to fit within the specified dimensions, adding padding if necessary, but doesn't scale it up. "fillPad" | Scales the image up or down to fill the specified dimensions, adding padding if necessary.

  1. Gravity?: - Specifies the gravity or position of the image. It can have one of the following values:

Gravity | Option Description ------------ | ------------- "face" | centers the image around detected faces. "auto" | automatically detects the subject of the image and centers it.

  1. cornerRadius?: number | "max"; - Specifies the radius of the corners of the image. It accepts a number value that represents the radius in pixels or the string value "max" that sets the maximum possible radius.

  2. rotate?: number; - Rotates the image by a specified angle in degrees.

  3. effects?: - Applies various effects to the image. It can have one or more of the following values:

Effect | Option Description ------------ | ------------- "blur" | blurs the image. "grayscale" | converts the image to grayscale. "sepia" | adds a sepia tone to the image. "shadow" | adds a drop shadow to the image. "colorize" | applies a color overlay to the image. "oilPaint" | applies an oil painting effect to the image. "cartoonify" | applies a cartoon effect to the image. "outline" | adds an outline to the image. "blackwhite" | converts the image to black and white. "makeTransparent" | makes the background of the image transparent. "vectorize" | converts the image to a vector format. "gradientFade" | applies a gradient fade effect to the image. "assistColorBlind" | simulates the experience of color blindness. "backgroundRemoval" | removes the background of the image. "dropShadow" | adds a drop shadow to the image.

In order to use backgroundRemoval you must activate Cloudinary AI Background Removal on Addons of your Cloudinary account. The backgroundRemoval must be allways the first effect

✅ Live Example

If you want to view live examples of the component, clone this repo and npm run dev it.

If you want to report any issues or have found a missing feature, please report it on GitHub!

Good luck out there, Astronaut. 🚀