![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
parse-cloud-image
Advanced tools
Parse Cloud module for image manipulation using sharp
Install the module by npm
$ npm i -S parse-cloud-image
or using yarn
$ yarn add parse-cloud-image
Processing images can be done using the new file triggers on Parse Server introduced in version 4.2.0 All triggers can be found here
Define beforeSaveFile
trigger:
import { ParseImage } from 'parse-cloud-image'
Parse.Cloud.beforeSaveFile(async (request: Parse.Cloud.FileTriggerRequest) => {
const image = ParseImage.from(request.file)
return image.resize(256)
})
Create ParseImage
to make image manipulations. If the file is not an image file error will be thrown.
ParseImage
wraps a ParseFile
and provides several basic methods for manipulations:
When both a width and height are provided, aspect ratio will be preserve, ensure the image covers both provided dimensions by cropping/clipping to fit. For more options check sharp's documentation and use process
method below
const image = ParseImage.from(parseFile)
image.resize(256, 128)
Rotate the image by specified angle. For more options check sharp's documentation and use process
method below
const image = ParseImage.from(parseFile)
image.rotate() // auto-rotated using EXIF Orientation tag
Scaling the image by specified factor. For more options check sharp's documentation and use process
method below
const image = ParseImage.from(parseFile)
image.scale(1.0, 0.5)
These methods are the heart of the ParseImage
giving elegant access to all capabilities of sharp
over given ParseFile
. Let's say you need to flip and rotate the image. This can be done like this:
const image = ParseImage.from(parseFile)
const processedImage = await image.edit(proc => proc.flip().rotate().toBuffer())
}
At the end the closure must return Buffer
from the chain of actions which will be serialized as new ParseFile
.
In some cases you would need option to manipulate in parallel image or create multiple different changes on different clones
of the image. This can be done with sharp
and the process
method of ParseImae
providing a Sharp
instances which can be piped.
const file = bucket.file("image.jpg").createWriteStream()
const image = ParseImage.from(parseFile)
...
image.process(sharp => sharp.resize(width, height)).pipe(file)
FAQs
Parse Server Cloud module for image manipulation using sharp
The npm package parse-cloud-image receives a total of 2 weekly downloads. As such, parse-cloud-image popularity was classified as not popular.
We found that parse-cloud-image demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.