Skip to content
75 changes: 75 additions & 0 deletions packages/docs/src/content/docs/guides/background-removal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Guides/Background Removal
order: 1
Comment thread
ghostdevv marked this conversation as resolved.
Outdated
---

<script>
Comment thread
ghostdevv marked this conversation as resolved.
Outdated

import Callout from '$lib/components/Callout.svelte'
import { Tabs, Tab} from '$lib/components/Tabs'
import { CldOgImage, CldImage } from 'svelte-cloudinary'

</script>

# Removing a Background from an Image

The CldImage component allows you to easily remove backgrounds from images using the `removeBackground` prop.

<Callout emoji={false}>
Removing backgrounds require enabling the <a href="https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon">Cloudinary AI Background Removal Add-On</a> which includes a free tier for getting started.
</Callout>
Comment thread
ghostdevv marked this conversation as resolved.
Outdated

## Example

<div style="max-width: 500px; margin: 0 auto">
<CldImage
Comment thread
ghostdevv marked this conversation as resolved.
Outdated
width={960}
height={600}
src={`images/turtle`}
sizes="(max-width: 480px) 100vw, 50vw"
removeBackground
alt=""
/>
</div>

<Tabs>
<Tab type="code" open title="CldImage">
Comment thread
ghostdevv marked this conversation as resolved.
Outdated

```svelte
<script>
import { CldImage } from 'svelte-cloudinary';
</script>

<CldImage
width="960"
height="600"
src="images/turtle"
sizes="100vw"
removeBackground
alt="Turtle"
/>
```

</Tab>
<Tab title="getCldImageUrl">

Comment thread
ghostdevv marked this conversation as resolved.
Outdated
```html
<script>
import { getCldImageUrl } from 'svelte-cloudinary';

const cldUrl = getCldImageUrl({
width: 960,
height: 600,
src: 'images/turtle',
removeBackground: true
});
</script>
```

</Tab>
</Tabs>

## Learn More

- [CldImage](/cldimage/usage)
- [getCldImageUrl](/getcldimageurl/usage)
73 changes: 73 additions & 0 deletions packages/docs/src/content/docs/guides/image-optimization.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Guides/Image Optimization
order: 2
---

<script>

import Callout from '$lib/components/Callout.svelte'
import Video from '$lib/components/Video.svelte'
import { Tabs, Tab} from '$lib/components/Tabs'
import { CldOgImage, CldImage } from 'svelte-cloudinary'

</script>
Comment thread
ghostdevv marked this conversation as resolved.
Outdated

# Optimizing Images in Svelte/SvelteKit

Automatically optimize images using the CldImage component. By default, CldImage opts you in to automatic optimization including delivering the most optimal format for the browser (WebP, AVIF).

You can further optimize delivery by using [responsive sizing](/guides/responsive-images) by using the `sizes` prop.

## Example

<div style="max-width: 500px; margin: 0 auto">
<CldImage
width="960"
height="600"
src={`images/turtle`}
sizes="100vw"
alt="Turtle"
/>
</div>

<Tabs tabs={['CldImage', 'getCldImageUrl']}>
<Tab type="code" open title="CldImage">

```svelte
<script>
import { CldImage } from 'svelte-cloudinary';
</script>

<CldImage width="960" height="600" src="images/turtle" sizes="100vw" alt="Turtle" />
```

</Tab>
<Tab type="code" title="getCldImageUrl">

```svelte
<script>
import { getCldImageUrl } from 'svelte-cloudinary';

getCldImageUrl({
width: 960,
height: 600,
src: 'images/turtle'
});
</script>
```

</Tab>
</Tabs>

## Watch & Learn

<Video
title="Optimize Images, Responsive Sizing, & AI Cropping in Svelte with Svelte Cloudinary"
url="https://www.youtube.com/watch?v=Vr3H3XREkbw"
/>
Comment thread
ghostdevv marked this conversation as resolved.
Outdated

## Learn More

- [Responsive Images](/guides/responsive-images)
- [CldImage](/cldimage/usage)
- [getCldImageUrl](/getcldimageurl/usage)
121 changes: 121 additions & 0 deletions packages/docs/src/content/docs/guides/image-overlays.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: Guides/Image Overlays
order: 3
Comment thread
ghostdevv marked this conversation as resolved.
Outdated
---

<script>

import Callout from '$lib/components/Callout.svelte'
import Video from '$lib/components/Video.svelte'
import { Tabs, Tab} from '$lib/components/Tabs'
import { CldOgImage, CldImage } from 'svelte-cloudinary'

</script>

# Overlaying Images

You can add images on top of other images by using image-based overlays.

## Example

<div style="max-width: 500px; margin: 0 auto">
<CldImage
width="960"
height="600"
src={`images/turtle`}
sizes="100vw"
overlays={[{
publicId: 'images/earth',
position: {
x: 50,
y: 50,
gravity: 'north_west',
},
effects: [
{
crop: 'fill',
gravity: 'auto',
width: 500,
height: 500
}
]
}]}
alt="Turtle with earth"
/>
</div>

<Tabs tabs={['CldImage', 'getCldImageUrl']}>
<Tab type="code" open title="CldImage">

```svelte
<script>
import { CldImage } from 'svelte-cloudinary';
</script>

<CldImage
width="960"
height="600"
src="images/turtle"
sizes="100vw"
overlays={[
{
publicId: 'images/earth',
position: {
x: 50,
y: 50,
gravity: 'north_west'
},
effects: [
{
crop: 'fill',
gravity: 'auto',
width: 500,
height: 500
}
]
}
]}
alt="Turtle with earth"
/>
```

</Tab>
<Tab type="code" title="getCldImageUrl">

```svelte
<script>
import { getCldImageUrl } from 'svelte-cloudinary';

const cldUrl = getCldImageUrl({
width: 960,
height: 600,
src: 'images/turtle',
overlays: [
{
publicId: 'images/earth',
position: {
x: 50,
y: 50,
gravity: 'north_west'
},
effects: [
{
crop: 'fill',
gravity: 'auto',
width: 500,
height: 500
}
]
}
]
});
</script>
```

</Tab>
</Tabs>

## Learn More

- [CldImage](/cldimage/usage)
- [getCldImageUrl](/getcldimageurl/usage)
77 changes: 77 additions & 0 deletions packages/docs/src/content/docs/guides/image-underlays.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Guides/Image Underlays
order: 4
---

<script>

import Callout from '$lib/components/Callout.svelte'
import Video from '$lib/components/Video.svelte'
import { Tabs, Tab} from '$lib/components/Tabs'
import { CldOgImage, CldImage } from 'svelte-cloudinary'

</script>

# Adding Layers Under Images

Underlays function very similar to overlays in terms of options, however they **do not support text**.

See the examples above under Overlays to learn more about the available configurations.

## Example

<div style="max-width: 500px; margin: 0 auto">
<CldImage
width="960"
height="600"
src={`images/turtle`}
sizes="100vw"
removeBackground
underlay="images/galaxy"
alt="Turtle swimming in a galaxy"
/>
</div>

<Tabs tabs={['CldImage', 'getCldImageUrl']}>
<Tab type="code" open title="CldImage">

```svelte
<script>
import { CldImage } from 'svelte-cloudinary';
</script>

<CldImage
width="960"
height="600"
src="images/turtle"
sizes="100vw"
removeBackground
underlay="images/galaxy"
alt="Turtle swimming in a galaxy"
/>
```

</Tab>
<Tab type="code" title="getCldImageUrl">

```svelte
<script>
import { getCldImageUrl } from 'svelte-cloudinary';

const cldUrl = getCldImageUrl({
width: 960,
height: 600,
src: 'images/turtle',
removeBackground: true,
underlay: 'images/galaxy'
});
</script>
```

</Tab>
</Tabs>

## Learn More

- [CldImage](/cldimage/usage)
- [getCldImageUrl](/getcldimageurl/usage)
Loading