
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-smartcrop
Advanced tools
React hook for smartcrop.js to content aware image cropping with points of interest and facial recognition.
This is the React Hook version of jwagner/smartcrop.js + lokesh/color-thief with Typescript support.
We made this hook for Flyyer.io to enable developers to create content-aware marketing and social images but it is useful for any kind of project.

Install this dependency:
yarn add use-smartcrop
By default images are loading with crossOrigin="" prop. See this StackOverflow thread.
Common case usage:
import React from "react";
import { useSmartcrop, SmartcropStatus } from "use-smartcrop";
function App() {
const src = "https://images.pexels.com/photos/1496286/pexels-photo-1496286.jpeg";
// Width and height are required.
const [cropped, error] = useSmartcrop({ src }, { width: 200, height: 400, minScale: 1.0 });
if (error) {
console.error(error);
}
return (
<div>
{cropped && <img src={cropped} />}
</div>
);
}
const [dataURL, error] = useSmartcrop(
/**
* Properties of a <img> element.
* Smartcrop will not be executed (so `dataURL` will be null) if `src` is not provided.
* */
image: ComponentProps<"img"> | null | undefined,
/** See below */
options: CropOptions,
)
/**
* Arguments for `smartcrop.js`
* From: https://github.com/jwagner/smartcrop.js
*/
export interface CropOptions {
/**
* Minimal scale of the crop rect, set to `1.0` to prevent smaller than necessary crops (lowers the risk of chopping things off).
*/
minScale?: number;
/**
* Width of the crop you want to use.
*/
width: number;
/**
* Height of the crop you want to use.
*/
height: number;
/**
* Optional array of regions whose 'interestingness' you want to boost
*/
boost?: CropBoost[];
/**
* Optional boolean if set to `false` it will turn off the rule of thirds composition weight
*/
ruleOfThirds?: boolean;
debug?: boolean;
}
FAQs
React hook for smartcrop.js to content aware image cropping with points of interest and facial recognition.
We found that use-smartcrop 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.