
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@orchard9ai/cropper
Advanced tools
A React image cropping component with aspect ratio controls, built on top of react-image-crop
.
npm install @orchard9ai/cropper react-image-crop
# or
yarn add @orchard9ai/cropper react-image-crop
# or
pnpm add @orchard9ai/cropper react-image-crop
Note: react-image-crop
is now a peer dependency and must be installed separately for SSR compatibility.
This package requires the following peer dependencies:
{
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-image-crop": "^11.0.0"
}
import { CropModal, CropData } from '@orchard9ai/cropper';
import '@orchard9ai/cropper/styles'; // Import CSS styles
function App() {
const [showCropper, setShowCropper] = useState(false);
const handleCrop = async (cropData: CropData) => {
console.log('Crop data:', cropData);
// Send crop data to your API
await api.cropImage(imageId, cropData);
};
return (
<>
<button onClick={() => setShowCropper(true)}>Open Cropper</button>
{showCropper && (
<CropModal
imageUrl="https://example.com/image.jpg"
onClose={() => setShowCropper(false)}
onCrop={handleCrop}
/>
)}
</>
);
}
<CropModal
imageUrl="https://example.com/image.jpg"
previewUrl="https://example.com/preview.jpg"
onClose={() => setShowCropper(false)}
onCrop={handleCrop}
/>
<CropModal
imageUrl="https://example.com/image.jpg"
aspectRatio={1} // Square aspect ratio
onClose={() => setShowCropper(false)}
onCrop={handleCrop}
/>
<CropModal
imageUrl="https://example.com/image.jpg"
onClose={() => setShowCropper(false)}
onCrop={handleCrop}
labels={{
title: 'Recortar Imagen',
cancel: 'Cancelar',
apply: 'Aplicar',
loading: 'Procesando...',
loadingImage: 'Cargando imagen...',
original: 'Original',
selection: 'Selección',
aspectRatios: {
freeform: 'Libre',
square: 'Cuadrado',
landscape: 'Horizontal',
portrait: 'Vertical',
original: 'Original',
},
}}
/>
Prop | Type | Required | Description |
---|---|---|---|
imageUrl | string | Yes | URL of the image to crop |
onClose | () => void | Yes | Callback when modal is closed |
onCrop | (cropData: CropData) => Promise<void> | Yes | Callback with crop data |
previewUrl | string | No | Optional preview image URL |
isLoading | boolean | No | Shows loading state |
aspectRatio | number | No | Initial aspect ratio (e.g., 1 for square) |
labels | Labels | No | Custom labels for i18n |
interface CropData {
x: number; // X coordinate of crop area
y: number; // Y coordinate of crop area
width: number; // Width of crop area
height: number; // Height of crop area
original_width: number; // Original image width
original_height: number; // Original image height
regenerate_variants?: boolean;
}
interface Labels {
title?: string;
cancel?: string;
apply?: string;
loading?: string;
loadingImage?: string;
original?: string;
selection?: string;
aspectRatios?: {
freeform?: string;
square?: string;
landscape?: string;
portrait?: string;
original?: string;
};
}
This component uses Tailwind CSS for styling. Make sure to include the styles in your application:
import '@orchard9ai/cropper/styles';
If you're using Tailwind CSS in your project, ensure the package's files are included in your content
configuration:
// tailwind.config.js
module.exports = {
content: [
// ... your other content paths
'./node_modules/@orchard9ai/cropper/dist/**/*.{js,mjs}',
],
// ... rest of your config
};
For advanced use cases, you can access the crop store directly:
import { useCropStore } from '@orchard9ai/cropper';
function MyComponent() {
const { crop, aspectRatio, setAspectRatio } = useCropStore();
// Use store values and methods
}
The package exports several utility functions:
import {
formatDimensions,
getAspectRatioLabel,
percentCropToPixelCrop,
pixelCropToPercentCrop,
constrainCrop,
debounce,
} from '@orchard9ai/cropper';
If you're migrating from the original BulkUploadReview CropModal:
Import Changes:
// Before
import { CropModal } from '@/pages/BulkUploadReview/components/CropModal';
// After
import { CropModal } from '@orchard9ai/cropper';
import '@orchard9ai/cropper/styles';
Type Import Changes:
// Before
import { CropData } from '@/types/CropTypes';
// After
import { CropData } from '@orchard9ai/cropper';
Props: The component API remains the same, so no changes needed.
npm run storybook
npm run build
npm run typecheck
MIT
FAQs
A React image cropping component with aspect ratio controls
We found that @orchard9ai/cropper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.