-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
256 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const ACCEPTED_EXTENSIONS = ['jpg', 'png', 'webp', 'tif'] | ||
export const MINIATURE_HEIGHT = 400 | ||
export const MINIATURE_QUALITY = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sharp from 'sharp' | ||
import { MINIATURE_HEIGHT, MINIATURE_QUALITY } from 'src/lib/images/constants' | ||
|
||
type Miniature = { | ||
buffer: Buffer | ||
mime: string | ||
} | ||
export async function getMiniature(imageBuffer: Buffer): Promise<Miniature> { | ||
const sharpThumbnail = await sharp(imageBuffer) | ||
.resize({ | ||
height: MINIATURE_HEIGHT, | ||
}) | ||
.webp({ | ||
quality: MINIATURE_QUALITY, | ||
}) | ||
.toBuffer() | ||
|
||
return { | ||
buffer: sharpThumbnail, | ||
mime: 'image/webp', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import type { FindImageById } from 'types/graphql' | ||
import type { CellSuccessProps } from '@redwoodjs/web' | ||
|
||
const static_server_url = process.env['STATIC_SERVER_URL'] | ||
const PHOTOS_PREFIX = process.env['PHOTOS_URL'] | ||
const MINATURES_PREFIX = process.env['MINIATURES_URL'] | ||
|
||
export function getImageUrl(image: CellSuccessProps<FindImageById>['image']) { | ||
return `${static_server_url}/${image.path}` | ||
return `${PHOTOS_PREFIX}/${image.path}` | ||
} | ||
export function getMiniatureUrl( | ||
image: CellSuccessProps<FindImageById>['image'] | ||
) { | ||
return `${MINATURES_PREFIX}/${image.path}` | ||
} |
Oops, something went wrong.