Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

✂️ Function for cropping an image through its ImageData.

License

NotificationsYou must be signed in to change notification settings

duniul/crop-image-data

Repository files navigation

✂️ Function for cropping an image through itsImageData.

Demo

https://crop-image-data.netlify.app

Installation

# npmnpm install crop-image-data# pnpmpnpm install crop-image-data# yarnyarn add crop-image-data

Usage

cropImageData(imageData, cropOptions)

Creates a cropped version of an ImageData-instance. Does not mutate the recieved instance.

Parameters:

  • imageData - the ImageData-instance instance to crop

  • cropOptions - an object specifying the amount of pixels to crop from each side

    • top - number of pixels to crop from the top
    • right - number of pixels to crop from the right side
    • bottom - number of pixels to crop from the bottom
    • left - number of pixels to crop from the left side

Return value:

A new, cropped ImageData-instance.

Examples:

importcropImageDatafrom'crop-image-data';// crop 5 pixels on every sideconstcropped=cropImageData(imageData,{top:5,right:5,bottom:5,left:5});// crop 50 pixels from the topconstcroppedTop=cropImageData(imageData,{top:50});// crop 10 pixels on each sideconstcroppedSides=cropImageData(imageData,{left:10,right:10});

Related packages

  • trim-image-data - finds and trims whitespace (or a specified color) from an image usingcrop-image-data

[8]ページ先頭

©2009-2025 Movatter.jp