File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,16 +107,25 @@ const cropGif = async path => {
107107 const { width : newWidth , height : newHeight } = await sharp (
108108 resized
109109 ) . metadata ( ) ;
110+ // console.log({ newWidth, newHeight });
110111
111- const offsetX = ( newWidth - CONTAINER_WIDTH ) / 2 ;
112- const offsetY = ( newHeight - MINIMUM_HEIGHT ) / 2 ;
112+ const offsetX = Math . floor ( ( newWidth - CONTAINER_WIDTH ) / 2 ) ;
113+ const offsetY = Math . floor ( ( newHeight - MINIMUM_HEIGHT ) / 2 ) ;
113114 const files = [ ] ;
114115 for ( let i = 0 ; i < 6 ; i ++ ) {
115116 const filename = `${ name } .${ i } .gif` ;
116117 const { x, y } = getXY ( i ) ;
118+ const xPos = x + offsetX ;
119+ const yPos = y + offsetY ;
120+ // console.log({
121+ // xPos,
122+ // yPos,
123+ // CUT_WIDTH,
124+ // CUT_HEIGHT
125+ // });
117126 await execa ( gifsicle , [
118127 "--crop" ,
119- `${ x + offsetX } ,${ y + offsetY } +${ CUT_WIDTH } x${ CUT_HEIGHT } ` ,
128+ `${ xPos } ,${ yPos } +${ CUT_WIDTH } x${ CUT_HEIGHT } ` ,
120129 "-o" ,
121130 filename ,
122131 resized
You can’t perform that action at this time.
0 commit comments