chore: remove flip x and y

This commit is contained in:
Ibrahima G. Coulibaly
2025-07-07 01:50:20 +01:00
parent 3eaf8e41b0
commit 72c6cc541c
3 changed files with 6 additions and 31 deletions

View File

@@ -14,7 +14,7 @@ import ToolFileResult from '@components/result/ToolFileResult';
import { processImage } from './service'; import { processImage } from './service';
const initialValues: InitialValuesType = { const initialValues: InitialValuesType = {
rotateAngle: '0', rotateAngle: '90',
rotateMethod: 'Preset' rotateMethod: 'Preset'
}; };
@@ -73,9 +73,7 @@ export default function RotateImage({ title }: ToolComponentProps) {
options={[ options={[
{ label: '90 degrees', value: '90' }, { label: '90 degrees', value: '90' },
{ label: '180 degrees', value: '180' }, { label: '180 degrees', value: '180' },
{ label: '270 degrees', value: '270' }, { label: '270 degrees', value: '270' }
{ label: 'Flip horizontally', value: 'flip-x' },
{ label: 'Flip vertically', value: 'flip-y' }
]} ]}
/> />
</Box> </Box>
@@ -118,7 +116,7 @@ export default function RotateImage({ title }: ToolComponentProps) {
value={input} value={input}
onChange={setInput} onChange={setInput}
title={'Input Image'} title={'Input Image'}
accept={['image/jpeg', 'image/png', 'image/svg+xml', 'image/gif']} accept={['image/*']}
/> />
} }
resultComponent={ resultComponent={

View File

@@ -18,19 +18,7 @@ export const processImage = async (
// Get current transform attribute or create new one // Get current transform attribute or create new one
let currentTransform = svgElement.getAttribute('transform') || ''; let currentTransform = svgElement.getAttribute('transform') || '';
// Calculate rotation angle const angle = parseInt(rotateAngle);
let angle = 0;
if (rotateMethod === 'Preset') {
if (rotateAngle === 'flip-x') {
currentTransform += ' scale(-1,1)';
} else if (rotateAngle === 'flip-y') {
currentTransform += ' scale(1,-1)';
} else {
angle = parseInt(rotateAngle);
}
} else {
angle = parseInt(rotateAngle);
}
// Add rotation if needed // Add rotation if needed
if (angle !== 0) { if (angle !== 0) {
@@ -65,18 +53,7 @@ export const processImage = async (
await ffmpeg.writeFile('input', await fetchFile(file)); await ffmpeg.writeFile('input', await fetchFile(file));
// Determine rotation command // Determine rotation command
let rotateCmd = ''; const rotateCmd = `rotate=${rotateAngle}*PI/180`;
if (rotateMethod === 'Preset') {
if (rotateAngle === 'flip-x') {
rotateCmd = 'hflip';
} else if (rotateAngle === 'flip-y') {
rotateCmd = 'vflip';
} else {
rotateCmd = `rotate=${rotateAngle}*PI/180`;
}
} else {
rotateCmd = `rotate=${rotateAngle}*PI/180`;
}
// Execute FFmpeg command // Execute FFmpeg command
await ffmpeg.exec([ await ffmpeg.exec([

View File

@@ -1,4 +1,4 @@
export type InitialValuesType = { export type InitialValuesType = {
rotateAngle: string | 'flip-x' | 'flip-y'; // the angle to rotate the image rotateAngle: string; // the angle to rotate the image
rotateMethod: 'Preset' | 'Custom'; rotateMethod: 'Preset' | 'Custom';
}; };